Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    139
    Thanks
    8
    Thanked 0 Times in 0 Posts

    identical scripts - only one works

    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=ht...com%2Ftest.htm)
    Why? How do I fix this?
    See the test page at http://www.leeaaron.net/dotcom/test.htm

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    139
    Thanks
    8
    Thanked 0 Times in 0 Posts
    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.)

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    139
    Thanks
    8
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    139
    Thanks
    8
    Thanked 0 Times in 0 Posts
    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! )


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •