Welcome to WebmasterWorld Guest from 54.144.48.252

Forum Moderators: incrediBILL

Message Too Old, No Replies

Replacement for target=' blank' isn't working

Rel='_blank' not working

     
9:51 am on Aug 8, 2012 (gmt 0)



So, since W3C has 'dropped' the target='_blank' attribute, I decided to look up another solution to ensure that my link would open up into a new window.
However, when i entered the code in my header, when clicking on the link my page just opens in the same window. I have tried both options!

help? :(

this is the site for reference, i'm referring to the home page code

[edited by: engine at 11:45 am (utc) on Aug 8, 2012]
[edit reason] see TOS [/edit]

9:59 am on Aug 8, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



i dont know about the that code, but this is what i use, which works okay

function externalLinks(){if(!document.getElementsByTagName){return;}var anchors=document.getElementsByTagName("a");for(var i=0;i<anchors.length;i++){var anchor=anchors[i];if(anchor.getAttribute("href")&&(anchor.getAttribute("rel")=="external"||anchor.getAttribute("rel")=="external nofollow"||anchor.getAttribute("rel")=="nofollow external")){anchor.target="_blank";}}}
externalLinks();


this is what you would use for the links...

<a href="blah" rel="external">

or
<a href="blah" rel="nofollow external">

or
<a href="blah" rel="external nofollow">


any of those will open in a new window
10:05 am on Aug 8, 2012 (gmt 0)



i did what you suggested and still no luck? :( take a look at the code, is there something i've done wrong?
11:15 am on Aug 8, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



since W3C has 'dropped' the target='_blank' attribute

Says who where? I thought that whole issue was settled years ago.

A valid browsing context name or keyword is any string that is either a valid browsing context name or that is an ASCII case-insensitive match for one of: _blank, _self, _parent, or _top.

b/w
User agent implementors are encouraged to provide a way for users to configure the user agent to always reuse the current browsing context.

Nice :) Browsers should recognize it, but they should also enable users to override it.
2:06 pm on Aug 8, 2012 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month




since W3C has 'dropped' the target='_blank' attribute


Says who where? I thought that whole issue was settled years ago.

It was deprecated in HTML 4.01. Looking at the HTML 4.01 Strict DTD [w3.org] you'll find that it's missing from the <!ATTLIST A ...> section. The HTML 4.01 Transitional DTD [w3.org] includes it because the Transitional DTD includes deprecated elements and attributes.
In HTML5 it is no longer deprecated.
With that said, though, there are still good usability arguments to be made for not using it (and of course, there are also some valid cases for using it as well).
2:29 pm on Aug 8, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The javascript just adds it back in, so anybody wanting to avoid using it: it's pointless to try it via that javascript. Something that would call window.open() would be a different story.

But the main point is that while it's frowned upon in the old html4, it's valid in (x)html5, and hence it's valid as long as you use the current html version.

The (x)html5 references:
Target on an <a> element: [w3.org...]
Valid browsing contexts (the value for target=): [w3.org...]

Usability: I have strong doubts on using it, esp when you see the high percentage of users on mobile devices nowadays ...
 

Featured Threads

Hot Threads This Week

Hot Threads This Month