Jump to content

What is the replacement for target="_blank", if any?


blogsmith
 Share

Recommended Posts

Here's one way to do it: <a href="xx.htm" onclick="window.open(this.href); return false;">There's other ways, check google...

Link to comment
Share on other sites

I think something like this is the best approach

<a href="http://www.google.com" onclick="return !window.open(this.href)">Google</a>

that way if the new window is blocked by a popup blocker then the link still forwards it he same window.

Link to comment
Share on other sites

You guys seem to be missing the point. W3c Standards suggest that the web page should not open another page from a link on the page which a client is viewing. Any new page should over-write the current page. This feature allows for the client to control the source and number of pages they have opened at one time. Whether you use (x)html (target=blank) or Javascript (onclick="window.open(this.href); return false;) doesn't matter. The fact remains that either of these methods open another window or tab in the client's browser. And the Standards suggest this is not correct.

Link to comment
Share on other sites

You guys seem to be missing the point. W3c Standards suggest that the web page should not open another page from a link on the page which a client is viewing. Any new page should over-write the current page. This feature allows for the client to control the source and number of pages they have opened at one time. Whether you use (x)html (target=blank) or Javascript (onclick="window.open(this.href); return false;) doesn't matter. The fact remains that either of these methods open another window or tab in the client's browser. And the Standards suggest this is not correct.
We say it is. :)I'm of the firm belief anyway that if you have links pointing to off-domain sites, then it is okay to have them open in a new window. It should then be written (link opens in a new window) or something similar, but that again is "ethical" more than compulsory.
Link to comment
Share on other sites

There was a discussion in the past too, about whether the decision of W3C to exclude the target attribute from the strict DTD, and we came to the conclusion that it may be used in certain situasions, like Jonas says above.I don't know if it is there already, but I have read somewhere there was an advanced update to this attribute in CSS. Like controlling the targets name, type, that sort of things. However, I have never seen it in action :)For now, there is no direct replacement for this attribute besides using just the target attribute, or a script like aspnetguy explains :) The W3C are too humans, and humans make decisions, not always the best one.

Link to comment
Share on other sites

Precisely! Thats what I meant. I see its CSS3, though IE only supports 1 and partly 2, FF I'm not sure, so let alone CSS3 :)It comes down to using the target attribute dispite of the DTD, or just using Transitional, or using javascript for each and every hyperlink :)

Edited by Dan The Prof
Link to comment
Share on other sites

Precisely! Thats what I meant. I see its CSS3, though IE only supports 1 and partly 2, FF I'm not sure, so let alone CSS3 :)It comes down to using the target attribute dispite of the DTD, or just using Transitional, or using javascript for each and every hyperlink :)
You don't need that lengthy piece of javascript for each link, instead you write one script and then use the "rel" attribute for each link.More in these topics:target attribute in Strict XHTMLReplacement of 'Target' Attribute in 4.01 Strict?
Link to comment
Share on other sites

  • 1 month later...

I can't see your point....

 target="_blank"

is very simple and easy to learn, so why do you want to use javascript instead of html? In my opinion, html is much easier than javascript...and btw, what's the difference between them? they both do the same thing...and none of them is depreciated, or at least w3schools doesn't say anything about this....

Link to comment
Share on other sites

I can't see your point....
 target="_blank"

is very simple and easy to learn, so why do you want to use javascript instead of html? In my opinion, html is much easier than javascript...and btw, what's the difference between them? they both do the same thing...and none of them is depreciated, or at least w3schools doesn't say anything about this....

Html is easier, but this attribute is deprecated according to W3C, they do say something about it.Though we don't think it should.The difference is that javascript can be universal for every link (if you use a function), and the target attribute is repetitive for each link, so may be hard to update.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...