img name="" validation question

Discussion in 'HTML' started by cruiserweight, Aug 20, 2005.

  1. 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
    advance!
     
    cruiserweight, Aug 20, 2005
    #1
    1. Advertising

  2. "cruiserweight" <> wrote:

    > 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,


    Thatäs true.

    > but if i take it out the code breaks in IE.


    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, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Aug 20, 2005
    #2
    1. Advertising

  3. cruiserweight

    Toby Inkster Guest

    cruiserweight wrote:

    > 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.


    Take out the name attribute and then fix the Javascript to look at the ID
    attribute.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Now Playing ~ ./andreas_johnson/liebling/07_patiently.ogg
     
    Toby Inkster, Aug 20, 2005
    #3
  4. cruiserweight

    Neredbojias Guest

    With neither quill nor qualm, cruiserweight quothed:

    > 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
    > advance!


    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]...

    --
    Neredbojias
    Contrary to popular belief, it is believable.
     
    Neredbojias, Aug 20, 2005
    #4
  5. 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 ; }

    Sweet.
     
    cruiserweight, Aug 21, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.austin.rr.com

    how to download img from html img tag

    news.austin.rr.com, Apr 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    544
    Steve C. Orr [MVP, MCSD]
    Apr 27, 2005
  2. Philipp Lenssen

    Problem: <img></img>

    Philipp Lenssen, Jun 27, 2005, in forum: XML
    Replies:
    15
    Views:
    807
    David Håsäther
    Jul 3, 2005
  3. Keith G Hicks
    Replies:
    10
    Views:
    530
    Fernando Rodriguez, MCP
    May 1, 2008
  4. Jopek
    Replies:
    7
    Views:
    430
    dorayme
    Apr 26, 2009
  5. Replies:
    7
    Views:
    211
    Tad McClellan
    Jun 22, 2006
Loading...

Share This Page