Avatar

External links (Features)

by Rövarn ⌂ @, Friday, November 22, 2013, 21:54 (1457 days ago)

Is it possible to modify so the links in posts open in new windows?

(My thought: If someone links to another interesting site a user who follow the link may be forgot where she / he came from and don't will be back for a while...)

Perhaps a choice in the admin panel in future versions?

Best regards
Micke

--
Just for fun...
[image]

Avatar

External links

by Milo ⌂, Saturday, November 23, 2013, 08:27 (1457 days ago) @ Rövarn

Hi,

Perhaps a choice in the admin panel in future versions?

No. This attribute is deprecated in XHTML, HTML4 (strict) and HTML5.

regards
Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

target=_blank is deprecated, not opening links in new tabs

by Bubba @, Sunday, November 24, 2013, 00:19 (1456 days ago) @ Milo
edited by Bubba, Sunday, November 24, 2013, 00:33

There are perfectly valid reasons for wanting this to be the default behavior for all links, like if your forum is in an iframe. I have one like that and had to hack the forum to open all links externally because users kept complaining when new sites popped up in the iframe the forum was in. There are plenty of other methods to get a link to open in a new tab or window, you don't have to use target="_blank".

Back in the day, opening external links in a new tab was considered the standard because you weren't supposed to rely on back button function as a way for the user to get back to your site.

All that said, I don't personally think it needs to be a feature, it's certainly easy enough for me to change on my own ;-)

Avatar

target=_blank is deprecated, not opening links in new tabs

by Milo ⌂, Sunday, November 24, 2013, 08:41 (1456 days ago) @ Bubba

Hi,

you are right, in HTML5 the old lady was reactivated.

when new sites popped up in the iframe the forum was in.

You have recognized the problem with the frame - solve it. ;-)

regards
Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

I fixed that a long time ago ;)

by Bubba @, Monday, November 25, 2013, 01:04 (1455 days ago) @ Milo

I couldn't believe they deprecated target in the first place, that was very short sighted of the consortium and done with a lot of protest from developers.

Adding the link target was the easy part, as I posted in my response to the main topic, it took about 10 minutes to figure out and complete, making that post took far longer. That's why I don't think it needs to be feature. Working out the iframe issues took a couple of hours but wasn't all that difficult either, you just need to be thorough ;-)

The code is laid out logically and it's well organized and commented, I've done a lot of customization and it's always been pretty easy. Kudos to everyone on the development team :-)

For the benefit of anyone that got this far looking for answers on working from within an iframe, I'll add the following. You will need make several other changes to the forum code and your website to get the forum operating correctly in an iframe. But that's not the point of this thread so I won't go into the particulars here ;-)

Target _blank is still good under html5

by Bubba @, Sunday, November 24, 2013, 01:31 (1456 days ago) @ Milo

There were several things they originally thought about deprecating and then reversed on, so I looked it up and target _blank is one of them. To quote the W3 website:

NOTE The target attribute on the a element was deprecated in a previous version of HTML, but is no longer deprecated, as it useful in Web applications, particularly in combination with the iframe element.

Here's the page a -- hyperlink

External links

by Mad, Sunday, November 24, 2013, 01:09 (1456 days ago) @ Rövarn

Yes

It's not that difficult

by Bubba @, Sunday, November 24, 2013, 01:10 (1456 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/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 :-D

Avatar

It's not that difficult

by Rövarn ⌂ @, Sunday, November 24, 2013, 19:57 (1455 days ago) @ Bubba
edited by Rövarn, Sunday, November 24, 2013, 20:51

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:

I believe that's it, enjoy :-D


Yes it works, thank You! :-)

Micke

--
Just for fun...
[image]

External links

by simon12 ⌂, Tuesday, January 14, 2014, 05:31 (1405 days ago) @ Rövarn

It goes like this:

<a href="this.is.mylink.com" target="_blank">This is my cool link</a>

However I strongly suggest you NOT do that. Most people know 'right click and open in new tab' now and they'll be annoyed.:-)

Avatar

External links

by Rövarn ⌂ @, Saturday, July 29, 2017, 18:20 (112 days ago) @ simon12

However I strongly suggest you NOT do that. Most people know 'right click and open in new tab' now and they'll be annoyed.:-)

Most may, but not all. In addition, it does not matter if you apply the function, the result of the 'most people' right-clicking will be the same!
;-)

Micke

--
Just for fun...
[image]

RSS Feed of thread
powered by my little forum