img name="" validation question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am using javascript to switch images. my image tags look like this:

<img src="image.jpg" width="610" height="200" alt="whatever"
name="picture" id="picture" />

obviously, 'name' is not valid with an xhtml strict doc type, but if i
take it out the code breaks in IE. Any thoughts, suggestions? thanks in

Re: img name="" validation question

Quoted text here. Click to load it

Thatäs true.

Quoted text here. Click to load it

It depends on what you do _elsewhere_.

You could upgrade to HTML 4.01 (there's no point in using XHTML on the web
really, except in the context of XML applications perhaps).

Or you could modify your JavaScript code so that it uses other techniques
to access the images, e.g. document.getElementById('picture') (which isn't
supported by very old JavaScript implementations, though).

Yucca, /
Pages about Web authoring:

Re: img name="" validation question

Good idea! This works for both IE and firefox and validates: I dropped
the "name='picture'" bit in the img tag, and changed my javascript code
from this:

function changeImage(img) { document.picture.src = img ; }

to this:

function changeImage(img) { document.getElementById('picture').src =
img ; }


Re: img name="" validation question

With neither quill nor qualm, cruiserweight quothed:

Quoted text here. Click to load it

Your javascript is probably archaic.  How many images are you switching?  
There's a fair chance that you don't even need to id (or name) the
images by using document.images[x]...

Contrary to popular belief, it is believable.

Site Timeline