24, July 2008

XHTML target=_blank - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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 1897 times)
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7974
40801 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 Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 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 : 4th of July Lottery from TemplateMonster.com
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7974
40801 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 Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 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 : 4th of July Lottery from TemplateMonster.com
I am a fanatic. So?
*****
Gender: Female
Posts: 599
3727 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 Visit through proxy, providing online content and printed marketing materials.
www.helpforwebbeginners.com Visit through proxy, Tutorials and how to's for new  webmasters.
www.CraftyTips.com Visit through proxy, a unique Arts & Crafts Directory
www.nocans.com Visit through proxy - Pet Food Recipe Site
www.petsiteguides.com Visit through proxy - A New Pet Directory

Last blog : What To Advertise
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 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 : 4th of July Lottery from TemplateMonster.com
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: 6280
38506 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 : 4th of July Lottery from TemplateMonster.com
Tim Nash
Global Moderator
Community Supporter ?
Internet Junkie
*****
Posts: 2172
5030 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 Visit through proxy
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 Visit through proxy alternatively for Social media optimisation take a look at the Venture Skills Blog Visit through proxy

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: 2172
5030 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 Visit through proxy alternatively for Social media optimisation take a look at the Venture Skills Blog Visit through proxy

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

Topic sponsors:
Get a permanent link here for $1.99!


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?
Jul 24, 2008, 11:23:29 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: 35.712
Total Topics: 7.376
Total Members: 3.706
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: FortuneBeach

36 Guests, 3 Users online :

12 users online today:



Readers

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