15 years on The Web
miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /   

Making urls open in the same window: _top

Author MKJ
#1 | Posted: 29 Jun 2006 09:14 
I am using the minibb forums to link to various sections of my site and would like to make all the urls open in the same window instead of a new window. These urls are being entered in the topics. Where can I find the code that controls this?

Author Paul
Lead Developer
#2 | Posted: 29 Jun 2006 11:11 | Edited by: Paul 
bb_func_txt.php: urlMaker()

bb_codes.php: encodeBB(), decodeBB()

replace "_blank" targets...

Or it's better to duplicate URL code and create additionally new code which will not open URL in new window. Something like [urls=....][/urls]

Author Bluesplayer
#3 | Posted: 11 Mar 2008 04:19 
Hi Paul

The above doesn't seem to work on the new forum I have just installed. What else do I need to do?

Author Paul
Lead Developer
#4 | Posted: 11 Mar 2008 10:37 | Edited by: Paul 
What exactly doesn't work? I see that your links are still opened in _blank target. So either you have improperly replaced this tag, either wrongly developed the new BB code... I don't know.

Author Bluesplayer
#5 | Posted: 11 Mar 2008 10:44 
Oops. It does work. I just realized that I had to alter the posts already made in the database or redo them for the alteration to take effect.

I am using this forum just to link to sections of my site internally so I didn't want new windows all over the place. Sorted now though with the above code changes.


Author Paul
Lead Developer
#6 | Posted: 12 Mar 2008 05:31 | Edited by: Paul 
Of course you will need to update the database manually... replacing "_blank" to "_top"... for example

update minibbtable_posts set post_text=REPLACE(post_text,'"_blank"','"_top"') where POSITION('"_blank"' IN post_text)>0;

or something like this...

Author Bluesplayer
#7 | Posted: 25 Nov 2008 04:11 | Edited by: Bluesplayer 
Hi Paul

I came across this code:

function formatLinks() {
var fileLink;
if (document.getElementById('ContentBody') && document.getElementById('ContentBody').getElementsByTagName('a')) {
for (var i = 0; fileLink = document.getElementById('ContentBody').getElementsByTagName('a')[i]; i++) {
if (fileLink.href.match(/^(http|https)/) && (fileLink.href.indexOf(location.hostname) == -1)) {
fileLink.setAttribute('target', '_blank');

var oldonload = window.onload;
if (typeof window.onload != 'function') { window.onload = function() { formatLinks(); }; }
else {
window.onload = function() {
if (oldonload) { oldonload(); }

This would be ideal for my use as I am referring to content on my shopping forum and off it. Internal links don't need a new window but offsite do. The above code is able to do that but needs adjusting for minibb. Bit beyond me. Are you able to use it or adjust it?


Edit: Come to think of it I could write a new tag couldn't I for this?

Author Paul
Lead Developer
#8 | Posted: 25 Nov 2008 04:58 
I don't understand how your code is related to this topic. It's pure JavaScript, we are talking here about PHP things.

I guess, yes it's possible just to program separate BB codes for URLs which begin with your own domain, or begins with any other domain, and they will use different target attributes. Example of BB codes containing your own URL only, are located here.

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications / Making urls open in the same window: _top Top

Your Reply Click this icon to move up to the quoted message

 Short link for this topic:

You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.

Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Try the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB