Replacement for 'target="_blank"

  • HongKongPhooey
  • Student
  • Student
  • User avatar
  • Posts: 86
  • Loc: Liverpool

Post 3+ Months Ago

If the 'target=_blank' attribute for a link is now deprecated, and not considered as valid XHTML , what's the alternative?

For the life of me I can't see how to get a link to open in a new window without using it, but a page will then fail XHTML 1 validation.

Any ideas?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Zwirko
  • Guru
  • Guru
  • User avatar
  • Posts: 1417
  • Loc: 55° N, 3° W

Post 3+ Months Ago

There are three ways that I can think of:

1) <a href="xx.htm" onclick="window.open(this.href); return false;">
2) This javascript workaround ... I use this myself.
3) Use HTML4.01 Srict doctype.


Option 3 is actually the most sensible and I would recommend it.
  • waffles
  • Student
  • Student
  • waffles
  • Posts: 67

Post 3+ Months Ago

Or you can use XHTML Transitional. That's what I do.
  • HongKongPhooey
  • Student
  • Student
  • User avatar
  • Posts: 86
  • Loc: Liverpool

Post 3+ Months Ago

Hmmmmm ...

thanks for the info.

Seems odd that we have to either use an older doctype or javascript to get this to work. I wonder if there's a good reason for this attribute being 'dropped' from the spec?

Personally I prefer to avoid Javascript, if possible, and I'd like to try and use XHTML where I can, but it looks like I have little choice here.

Thanks again for the advice though :) I shall take a look at the options tomorrow and see which one best fits my project. Your time is appreciated.
  • Zwirko
  • Guru
  • Guru
  • User avatar
  • Posts: 1417
  • Loc: 55° N, 3° W

Post 3+ Months Ago

re HTML 4.01 strict


This version is actually the most sensible to use at present.
Most of what you have read/heard about xhtml is simply not reality or even
true. The supposed advantages are non-existant. It can even be argued as
"bad" ... and has been done so many times across the web.
  • lioness
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1615

Post 3+ Months Ago

waffles wrote:
Or you can use XHTML Transitional. That's what I do.


Me too. All my pages are XHTML Strict except those (e.g. links pages) which I open in a new window from XHTML Transitional (Aside from the target=_blank my Transitional pages validate as Strict).

Not sure
  • HongKongPhooey
  • Student
  • Student
  • User avatar
  • Posts: 86
  • Loc: Liverpool

Post 3+ Months Ago

One day, life will be simple :roll:

It does rather prove that newer is not always better. Oh well, back to the drawing board. :D
  • Zwirko
  • Guru
  • Guru
  • User avatar
  • Posts: 1417
  • Loc: 55° N, 3° W

Post 3+ Months Ago

XHTML:

You can of course still use it ... I do so on my own site. In the end it doesn't
really matter.

I was just pointing out that there are great deal of myths regarding xhtml.

But ..... if you are "hardcore" then html4.01 strict is the way to go.
  • Shai
  • Born
  • Born
  • Shai
  • Posts: 1

Post 3+ Months Ago

I don't know about the politics of XHTML and why the deprecation but I believe that it is a bad practice to meddle with the user's browser behavior. If the user wants to open the link in a new tab or a new window, let the user to that with a right-click "open link in new tab/window."

I think target="_blank" gives site owners the illusion of controlling their user's experience. But in the end, I think they lose credibility with their users precisely because they are trying for control.

I can't deny that I'm not tempted to use it, but I try to resist.

I know the topic of this thread is how to create that behavior via valid xhtml. I just thought I'd argue for not using at all, which is the easiest solution.
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

I agree with Shai here. Good One.
  • dyfrin
  • Expert
  • Expert
  • User avatar
  • Posts: 503
  • Loc: WI

Post 3+ Months Ago

Yep, not sure if it's a myth, but browser control, pop-up craze, etc has had many start to think, control of using a site should be in the remote users hands.

Many instances where this just cannot be true, external sites you link to that you do not want them to misbelieve it is still your site, little help/informational windows, etc.

But if we are going for a separation of content vs presentation, it would also make sense to move content away from controls?
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

I'm going to keep using _blank for off-site links until it doesn't work anymore. :)
  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

Shai wrote:
I don't know about the politics of XHTML and why the deprecation but I believe that it is a bad practice to meddle with the user's browser behavior. If the user wants to open the link in a new tab or a new window, let the user to that with a right-click "open link in new tab/window."

I think target="_blank" gives site owners the illusion of controlling their user's experience. But in the end, I think they lose credibility with their users precisely because they are trying for control.

I can't deny that I'm not tempted to use it, but I try to resist.

I know the topic of this thread is how to create that behavior via valid xhtml. I just thought I'd argue for not using at all, which is the easiest solution.


Hang on then if you are saying that then why have any CSS? or for that matter why even have the link and not just tell the users with normal non-linked text the URL to go to?!

I use target=_blank becasue it is the easyst way, and in the same way I use the <b><i>and<u> tags rather then doing it in the CSS. POINT

Post Information

  • Total Posts in this topic: 13 posts
  • Users browsing this forum: No registered users and 65 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.