Forum Moderators: open

Message Too Old, No Replies

a link validation error

         

PowerUp

12:21 pm on Mar 24, 2007 (gmt 0)

10+ Year Member



hi, I have my HTML below, but when I validate, it says error. Can anyone help? Thanks.

<a target="_blank" href="http://www.widget.com/widget.html">Widgets!</a>

The tag: "a" doesn't have an attribute: "target" in currently active versions.[XHTML 1.0 strict]

penders

12:59 pm on Mar 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The
target
attribute is only valid for a Transitional (loose DTD) DOCTYPE. You cannot specify a target (to open a new window, ie. target="_blank") if you have to validate to a Strict DOCTYPE, which you are doing.

A way to get around this might be to use JavaScript in the onclick event of the anchor to

window.open
a new window...?

daveVk

1:20 pm on Mar 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you have a choice go with xhtml 1.0 Transitional, this works Ok with most current browsers, dont recall must downside.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

PowerUp

1:40 pm on Mar 24, 2007 (gmt 0)

10+ Year Member



? Does anyone know why this feature is removed from xhtml 1.0 strict? I guess I'll go back to html 4.01 strict

penders

2:32 pm on Mar 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Does anyone know why this feature is removed from xhtml 1.0 strict?

I'm guessing... in the interests of accessibility and removing presentation/behaviour from content... the target attribute is only really relevant for screen rendered content (?)

I guess I'll go back to html 4.01 strict

HTML 4.01 Strict is the the same as XHTML 1.0 Strict in this respect - you need to drop back to Transitional (XHTML or HTML).

tedster

3:28 pm on Mar 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



no version of HTML strict has ever included the target attribute.

[w3.org...]

The target attribute is intended for frameset DTDs.

PowerUp

5:38 pm on Mar 24, 2007 (gmt 0)

10+ Year Member



no version of HTML strict has ever included the target attribute.

If this is the case, then that means all visitors clicking on any outbound links will definitely leave your site since the url won't open in a new window.

Hmmm... have you guys come across this problem before? Did you compromise by using HTML transitional?

There's a suggestion earlier to use javascript to open a new window. However, this means that visitors with script blockers won't have the content opening in a new window.

Any other suggestions?

tedster

6:28 pm on Mar 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First, note that we're talking validation here -- not browser support.

One way to cater to folks with javascript turned off (and I believe the stats on that traffic segment are heavily inflated by bot traffic) is to serve a regular link, then an onclick javascript function with "return false" so the main page doesn't reload also when javascript is enabled.

<a href="newpage.html" onclick="popup('newpage.html','variable options');return false;">link text</a>

PowerUp

3:32 am on Mar 25, 2007 (gmt 0)

10+ Year Member



Hi tedster, you wrote..

<a href="newpage.html" onclick="popup('newpage.html');return false;">link text</a>

I tried to implement this but it doesn't work. The furthest I can go is this..

<a href="newpage.html" onclick="javascript:window.open('newpage.html'); return false;">

if "onclick popup" can cater to visitors with javascript turned off, then i'd assume that onclick popup is not a javascript. If it's not javascript, then what is it?

Is there any other code that I need to insert before <a href="newpage.html" onclick="popup('newpage.html');return false;">link text</a>

PowerUp

9:27 am on Mar 25, 2007 (gmt 0)

10+ Year Member



1.Will it hurt my SEO if i have javascript in my HTML?
2.If I don't use javascript and instead use target="_blank", and my page doesn't validate, will it hurt my SEO?

tedster

8:39 am on Mar 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there any other code that I need to insert

Yes - somewhere (head section, external js file) you need to define popup() to be the exact function you need for your situation. Sorry about my incompleteness. I was just trying to point in a direction, not create usable code.

penders

7:53 pm on Mar 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



if "onclick popup" can cater to visitors with javascript turned off, then i'd assume that onclick popup is not a javascript. If it's not javascript, then what is it?

The onclick event doesn't cater to visitors with javascript turned off - it caters to visitors with javascript turned ON. The href attribute caters to those who have javascript turned off - for those few, they won't get a popup, it will just be a regular link! "popup()" would be a javascript function that you would have to write yourself (as tedster suggests) - it is not a built-in javascript function. It would perhaps call the built-in window.open() function (a method of the window object).

You could call the window.open() function directly, like you have done, but if you have many popups it may be easier in the long run to write a function.

1. Will it hurt my SEO if i have javascript in my HTML?
2. If I don't use javascript and instead use target="_blank", and my page doesn't validate, will it hurt my SEO?

1. In this case, no. SE's generally/always ignore javascript. If, however, you used javascript to create page content/site navigation, then it probably would effect your SE rankings - as it would be as if it didn't exist!

2. I doubt it.