It's not that difficult (Features)

by Bubba @, Sunday, November 24, 2013, 01:10 (2190 days ago) @ Rövarn
edited by Bubba, Sunday, November 24, 2013, 01:36

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/, 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);


  $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>';


    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>';


    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>';


    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>';


    return $pre.'<a href="'.$url.'" target="_blank">'.$shortened_url.'</a>';

I believe that's it, enjoy :-D

Complete thread:

 RSS Feed of thread

powered by my little forum