Log in

View Full Version : How can I make link open in same window?


JimLink
08-27-2006, 05:04 AM
Is there a way to make Links or URLs posted by registered members of my forum that are in my forum or domain open in the current window rather than opening a new one?

vBulletin THEN DAYLIGHT
08-27-2006, 07:16 AM
You have to edit a PHP file: includes/class_bbcode.php

In this file, change

return "<a href=\"$rightlink\" target=\"_blank\">$text</a>";

to

return "<a href=\"$rightlink\">$text</a>";

And that should make the [url] tag open links in the same window.

JimLink
08-27-2006, 07:39 AM
thank you

alanw
11-01-2006, 08:54 PM
Actually that patch doesn't do what was asked and I have seen a number of people asking for a way to make links within the forum open in the same window but other (external) links open a new window.

I have done this successfully for my forum by making the patch conditional - eg, prefix the existing return statement with this where YOURURL is replaced by the URL prefix you require to match and XX is the length of the string to be matched (including the http://):


if ( vbstrlen($rightlink) > XX AND substr($rightlink, 0, XX) == "http://YOURURL")
{ return "<a href=\"$rightlink\">$text</a>";
}else

ElfMage
01-15-2007, 02:37 PM
This thread is 2 months old, but in case anybody else is looking for an alternate solution....

Edit the PHP file includes/class_bbcode.php, and in this file change:

return "<a href=\"$rightlink\" target=\"_blank\">$text</a>";

to


global $vbulletin;
if ((strpos( $rightlink, $vbulletin->options['bburl'] ) === 0)
|| (strpos( $rightlink, $vbulletin->options['homeurl'] ) === 0))
$target = '';
else
$target = 'target="_blank"';
return "<a href=\"$rightlink\" $target>$text</a>";