I know target="_blank" is deprecated, but the browsers still support it and will >for some time to come. If being 100% html strict compliant is really important to >you, there are other methods of getting it done
I originally thought this was true but I looked it up and it's in the html5 specification again, so target="_blank" is compliant
I have a forum that is in an iframe in a website, I modified it due to user complaints about new websites showing up inside the iframe. I've already done the work so I may as well pass it along to others. The changes that need to be made are all in the file includes/functions.inc.php
, you need to make the following changes:
in function make_link
on line 343 change
$string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "$1<a href=\"http://$2\">$2</a>", $string);
to
$string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "$1<a href=\"http://$2\" target=\"_blank\">$2</a>", $string);
in function do_bbcode_url
on line 478 change
if(!isset ($attributes['default'])) return '<a href="'.htmlspecialchars($content).'">'.htmlspecialchars(shorten_url($content)).'</a>';
to
if(!isset ($attributes['default'])) return '<a href="'.htmlspecialchars($content).'" target="_blank">'.htmlspecialchars(shorten_url($content)).'</a>';
and on line 480 change
return '<a href="'.htmlspecialchars ($attributes['default']).'">'.$content.'</a>';
to
return '<a href="'.htmlspecialchars ($attributes['default']).'" target="_blank">'.$content.'</a>';
in function do_bbcode_msg
change lines 499 and 500 from
if(!isset ($attributes['default'])) return '<a href="index.php?id='.intval($content).'" class="internal">'.intval($content).'</a>';
return '<a href="index.php?id='.intval($attributes['default']).'" class="internal">'.$content.'</a>';
to
if(!isset ($attributes['default'])) return '<a href="index.php?id='.intval($content).'" class="internal" target="_blank">'.intval($content).'</a>';
return '<a href="index.php?id='.intval($attributes['default']).'" class="internal" target="_blank">'.$content.'</a>';
in function shorten_link
on line 1205 change
return $pre.'<a href="'.$url.'">'.$shortened_url.'</a>';
to
return $pre.'<a href="'.$url.'" target="_blank">'.$shortened_url.'</a>';
I believe that's it, enjoy