homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

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)

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";}}}

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

<a href="blah" rel="external">
<a href="blah" rel="nofollow external">
<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)

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.

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)

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)

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 ...

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved