...

View Full Version : identical scripts - only one works



StickBoy
07-04-2003, 02:09 AM
The W3C Validator is driving me up the wall.
Can somebody please tell me why it picks an error out of one example but not another, even though they are exactly the same?

Here's what I have on my test page:

<A href="music.shtml" onMouseOver="imageSwap('music', 'music2.gif'); return true" onMouseOut="imageSwap('music', 'music.gif');"><IMG height=35 alt="Audio samples" NAME="music" src="music.gif" width=137 border=0></A>

<A href="music.shtml" onMouseOver="imageSwap('music', 'music2.gif'); return true" onMouseOut="imageSwap('music', 'music.gif');"><IMG height=35 alt="Audio samples" NAME="music" src="music.gif" width=137 border=0></A>

You will note that they are exactly the same. The reason is because I pasted the same thing twice.
For the first chunk, the Validator tells me " there is no attribute "NAME" "
But it does not say the same for the second chunk. (See for yourself: http://validator.w3.org/check?uri=http%3A%2F%2Fwww.leeaaron.net%2Fdotcom%2Ftest.htm)
Why? How do I fix this?
See the test page at http://www.leeaaron.net/dotcom/test.htm

Skyzyx
07-04-2003, 02:55 AM
All tags and attributes must be lowercase, since XML/XHTML is case-sensitive. "NAME" doesn't exist in the spec, but "name" does.

Also, I'm not sure if it's valid to have two elements with the same name...

Fix those, and it should work.

StickBoy
07-04-2003, 03:23 AM
It's not about the case or the fact that they are the same element. This problem came about on a page with a number of similar but differently named elements, but only the first one was tagged as being incorrect. They all use uppercase for "NAME", though I tried it with lowercase and still got the same error, but only on the first in the list.
The reason I have the test page with two exactly the same is to point out that one works and one doesn't, even though they are the same. (If it were a problem with them being the same name, wouldn't the first one work and the second one not? Or both not work, as is the case when you view the page in a browser.)

Graeme Hackston
07-04-2003, 04:24 AM
I don't know why it won't validate, try making everything lower case, a, img, onmouseover etc. Also, I don't know if using name= in an img tag is valid in HTML 4.0 transitional.

I do know that the validator doesn't display every error in a page. If you correct the 1st name problem and run it through the validator again it will pick up the 2nd.

StickBoy
07-04-2003, 06:06 AM
I use the exact same code in another page which validates just fine. The only difference is that the one that works has only one image, while this has more than one. If I use only one of these img/link tags, it still will not validate.
Maybe the Validator doesn't repeat "Name" errors, but I know it will repeat errors - I don't know how many times I've forgotten to add the "alt" tag to an img and it's come back with a page full of errors, all pointing at missing alts, so I know it repeats the same error message.

StickBoy
07-04-2003, 06:39 AM
NEVER MIND!

After about an hour of deconstructing my other page that works using this code, and having it validate, I noticed the number 1. That's right, the code that wouldn't work was on a page defined as HTML 4.0 ... the code that worked was on a page defined as HTML 4.01
I'm sorry for wasting your time - I'm an idiot! (I'm also very relieved I figured this out before I ripped out all of my hair! :rolleyes: )



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum