View Full Version : Thumbnail Viewer II validation problem

07-30-2005, 02:51 PM

I'm using the Thumbnail Viewer II with additional captions added as per the script available on this forum here: http://home.comcast.net/~jscheuer1/side/files/thumb2.htm

I've got it all validating to XHTML 1.0 strict except the name attribue part of the script in the thumbnail section which I can't get to validate as it says that name can only be a single word.

<a href="#" name="My Dog" onmouseover="modifyimage('dynloadarea', 0); get_cap(this.name);"><img src="images/dog.jpg" width="80" height="80" alt="My dog" /></a>

Is there any way round this?


Edit: I've tried changing the name attribute to id which works but again doesn't validate for the same reason. I've also tried adding a nonbreaking space character instead of an actual space but the validator doesn't like that either. In fact I've tried reducing the DOCTYPE and it won't have any of it! the only thing that works is an underscore but that is really ugly :(

2nd Edit: OK I solved the problem eventually! I swapped a title attribute for the name attribute and that works and validates! :D

07-30-2005, 07:46 PM
You could also do the same thing using the alt attribute, which would give you additional flexibility in some browsers. Also, you might be able to make up an attribute say, caption and if "this.caption" won't pass the data to the function, then "this.getAttribute('caption', 0)" should. The validator shouldn't mind what you set the caption attribute to but, it might object to it as an invalid attribute. All in all, worrying about these things validating when you are not using them for their designed purpose, is a bit of overkill. If, on the other hand, you needed to also use the name attribute for one of its intended uses, then you might need to worry. Generally, validators are more strict than browsers, even with a given doctype.

07-31-2005, 10:05 AM
Thanks for that.

I did actually try swapping the name attribute for caption but again the validator spat it back at me. In the end I would have stuck with the original name attribute and taken the hit at the validator - I just like to try to pass it if I can without pulling all my hair out!

Thanks again.

07-31-2005, 12:46 PM
More about the flexibility afforded by using the alt attribute. Using the title attribute, as you probably discovered, also has the effect of a tool tip onmouseover of the thumbnail image. By using the alt attribute and specifying a title like so:

title=""you get no tool tip. Or, you could specify a title different than the caption (now held in the alt attribute), and thereby achieve a tool tip different than the caption. All acceptable to the validator. However, the alt attribute will still be used for its intended purpose as well, text to be displayed if the image cannot be rendered.