Results 1 to 7 of 7

Thread: Image swap???

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Kalix, Norrbotten, SWEDEN
    Posts
    343

    Image swap???

    I want to make an image swap.

    I have a link, on this links onmouseover and onmouseout i want to change a image. How can i do this???


    /Smirre
    Visual Basic
    C, C++
    Java
    Access
    SQL Server

    MCP, MCSD

  2. #2
    Fanatic Member chrismitchell's Avatar
    Join Date
    Jan 2001
    Location
    With Hobbes in New Zealand
    Posts
    568
    onmouseover="pic('button','pic-off.gif')"
    onmouseout="pic('button','pic-on.gif')"

    I think thats how its done

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Kalix, Norrbotten, SWEDEN
    Posts
    343
    I have used this code to change the image:

    document.images['imagename'].src = image1.src;

    the image1 is created like this:

    image1 = new Image;
    image1.src = "grahpics/imagename.gif";


    is this syntax correct or???

    coudnt the documnet.images be set to the image1 object instead of the src of both objects??? or???

    /Smirre
    Visual Basic
    C, C++
    Java
    Access
    SQL Server

    MCP, MCSD

  4. #4
    Fanatic Member chrismitchell's Avatar
    Join Date
    Jan 2001
    Location
    With Hobbes in New Zealand
    Posts
    568
    Sorry thats gone over my head a bit .. What are you trying to do it in? JavaScript, XML or what?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Kalix, Norrbotten, SWEDEN
    Posts
    343
    javascript...
    Visual Basic
    C, C++
    Java
    Access
    SQL Server

    MCP, MCSD

  6. #6
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    You dont really have to use document.images, you can still use document.all or getElementById. Try this (edited from the code I posted for you this morning)...

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>

    <script language="JavaScript" type="text/javascript">
    <!--

    function changeImage(objectID,imageName){
    findDom(objectID).src = imageName;
    }

    function findDom(objectID){
    if (document.all){
    return document.all(objectID);
    } else if (document.getElementById){
    return document.getElementById(objectID);
    }
    }

    //-->
    </script>


    </head>
    <body>
    <img id="img1" src="image1.jpg" onmouseover="changeImage('img1','image1-2.jpg')" onmouseout="changeImage('img1','image1.jpg')">
    </body>
    </html>
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  7. #7
    Fanatic Member chrismitchell's Avatar
    Join Date
    Jan 2001
    Location
    With Hobbes in New Zealand
    Posts
    568
    Or if you are using Dreamweaver you can do it in the Rollover Image section..

Posting Permissions

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



Click Here to Expand Forum to Full Width