19, March 2010

XHTML target=_blank - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Design and Layout  >  Web Page Design  >  HTML & XHTML (Moderator: Meth0d)
Topic: XHTML target=_blank
« previous next »
Pages: [1] Print

Author Topic: XHTML target=_blank  (Read 3250 times)
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5659
45587 credits
Members referred : 3



« on: Aug 02, 2006, 11:18:47 pm »

I just realized, that the target="_blank" attribute in <a> tags is not allowed by the XHTML strict rules.

Do you know of any relevant attribute that open a link in a new window, that is XHTML valid?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6690
34708 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Aug 03, 2006, 01:02:20 am »

I just realized, that the target="_blank" attribute in <a> tags is not allowed by the XHTML strict rules.

Do you know of any relevant attribute that open a link in a new window, that is XHTML valid?
There is no attribute, maybe you get some javascript working...


Last blog : A new Wordpress theme for our blog
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5659
45587 credits
Members referred : 3



« Reply #2 on: Aug 03, 2006, 11:23:13 am »

Or maybe I'll leave it this way Smiley

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6690
34708 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Aug 03, 2006, 11:24:45 am »

Or maybe I'll leave it this way Smiley
this is one of the reasons that I use the xhtml transitional doc type...


Last blog : A new Wordpress theme for our blog
Bill Gates is my home boy
*****
Gender: Female
Posts: 710
4449 credits
Members referred : 2



« Reply #4 on: Aug 03, 2006, 04:32:39 pm »

I use transitional for everything too.

Depricate <b> and instead put class="something" and an entry for the formatting in a stylesheet - just silly if you ask me.

Didn't know target wasn't valid.

www.yourmessageconsultant.com, providing online content and printed marketing materials.
www.helpforwebbeginners.com, Tutorials and how to's for new  webmasters.
www.CraftyTips.com, a unique Arts & Crafts Directory
www.nocans.com - Pet Food Recipe Site
www.petsiteguides.com - A New Pet Directory

Last blog : Spring Cleaning at Crafty Tips
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6690
34708 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Aug 03, 2006, 04:50:21 pm »

I use transitional for everything too.

Depricate <b> and instead put class="something" and an entry for the formatting in a stylesheet - just silly if you ask me.

Didn't know target wasn't valid.

target="_blank" is not supported under strict is because specifying that attribute acts as something presentational, which is exactlly what XHTML is NOT intended for, the same is for the "b" element.

style is done by style sheets...in XML, actually it should be possible to parse a XHTML strict document like a regular xml document...


Last blog : A new Wordpress theme for our blog
Atari ST fan
*
Gender: Female
Posts: 8
56 credits
Members referred : 0



« Reply #6 on: Aug 11, 2007, 05:09:44 pm »

I was looking for an answer to this a month or two ago. It seems such a pain to have to use javascript when there could be such an easy way to do it in the HTML. Still haven't found a better answer though. And this is why I, and so many other people, use XHTML transitional even though the standards nazis look down their nose at it.
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6690
34708 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Aug 11, 2007, 05:25:08 pm »

I was looking for an answer to this a month or two ago. It seems such a pain to have to use javascript when there could be such an easy way to do it in the HTML. Still haven't found a better answer though. And this is why I, and so many other people, use XHTML transitional even though the standards nazis look down their nose at it.

if you need the blank target use a different doc type Wink


Last blog : A new Wordpress theme for our blog
Tim Nash
Global Moderator
Community Supporter ?
Internet Junkie
*****
Posts: 2175
5052 credits
Members referred : 2


Venture Skills - New Media & IT group


« Reply #8 on: Aug 12, 2007, 10:30:38 am »

If you have to use _blank and xhtml strict then you can always pass it to javascript
Code:
<a href="some.html" onclick="return ! window.open(this.href);">Targeted Keywords</a>

This is probably the shortest use of javascript to do this, however its a little on the ugly side and will return errors in a WAI audit (its valid as it degrades but will be flagged as a potential problem)

The method I prefer is detailed here
http://loadaveragezero.com/app/s9y/index.php?/archives/95-Serving-Valid-XHTML-Strict-with-target_blank.html
Slightly more code, and it presumes your _blank are for external sites, given if you have been working in XHTML strict and WAI guidelines you will have already been declaring external links, this is integrates nicely.

While not getting into the is dom hierarchy structure or presentation debate, XHTML strict is there for a reason if you need to hack it with Javascript I guess you have to ask why you are doing it. (I still do anyway!)

Would you like to be an SEO, let me help with, The Tim Nash introduction to SEO alternatively for Social media optimisation take a look at the Venture Skills Blog

Last blog : Its all in the mp3s
Kill the googlebot
*
Posts: 6
40 credits
Members referred : 0


« Reply #9 on: Nov 06, 2007, 07:29:57 pm »

It's easier to just don't use target=_blank.

I mean, it's the user who decides if the window will open in another window or not. What you should do is include (by CSS) a little icon on the link to warn the user in case of a external link (oh, and don't forget the "rel=external" attribute on the <a> tag)
Community Supporter ?
Hunky Junky Monky Man!
**
Gender: Male
Posts: 68
436 credits
Members referred : 0


Schwa?


« Reply #10 on: Jan 03, 2008, 03:43:48 am »

I would just like to add to daquino's post: if you create your a tags with 'rel="external"', you can write a script that will read in all of the tags (think: document.getElementsByTagName('a')) and check their rel attribute.  Then, you can add an onclick handler that will open a new window with the source of 'this.href' which is to point to the current a tag's url - and then of course return 'false' so the URL doesn't execute.

Tim Nash
Global Moderator
Community Supporter ?
Internet Junkie
*****
Posts: 2175
5052 credits
Members referred : 2


Venture Skills - New Media & IT group


« Reply #11 on: Jan 03, 2008, 11:48:55 am »

Just like the URL I posted 2 posts up as the preferred option.

The good news for those _blank lovers is it is in the html5 specs the bad news its not in the new xhtml specs so when the world decides which way it will go we might not need such hacks. Though it is worth remembering that many users find opening new windows very annoying unless their is a good reason. If you are worried your content is not good enough for them to come back perhaps you might want to look at that before implementing _blank of course their are dozens of other reasons as well many completely valid.

Would you like to be an SEO, let me help with, The Tim Nash introduction to SEO alternatively for Social media optimisation take a look at the Venture Skills Blog

Last blog : Its all in the mp3s
Kill the googlebot
*
Posts: 6
40 credits
Members referred : 0


« Reply #12 on: Jan 03, 2008, 02:50:40 pm »

but I still recommend not using "onclick" element, as long as aaron's solution is better
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3525
Tags : javascript xhtml xml Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Design and Layout  >  Web Page Design  >  HTML & XHTML (Moderator: Meth0d)
Topic: XHTML target=_blank
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Mar 19, 2010, 09:50:38 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 44.198
Total Topics: 8.620
Total Members: 8.230
Tutorials : 58
Resources : 929
Designs : 360
Latest Member: Nokian1

28 Guests, 4 Users online :

15 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2010 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.