#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    98
    Rep Power
    12

    Javascript rollover won't work


    For my site, I wanted a rollover image to go below my menu bar to give a brief summary about each link. The code I'm using is below. I checked other sites who use the exact same thing, and theirs works. However in my editor (1st page 2000) it gives me the error " 'document[...]' is null or not an object. I'm a bit confused why. Can anyone find the error? The code I'm using is below.

    <script language="JavaScript">
    <!--

    if (document.images) {
    image1on = new Image();
    image1on.src = "servicelinks1.png";

    image2on = new Image();
    image2on.src = "priceslinks2.png";

    image3on = new Image();
    image3on.src = "portfoliolinks3.png";

    image4on = new Image();
    image4on.src = "contactlinks4.png";

    image1off = new Image();
    image1off.src = "topbarspacing.png";



    }

    function changeImages() {
    if (document.images) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
    document[changeImages.arguments[i]].src = eval
    (changeImages.arguments[i+1] + ".src");
    }
    }
    }


    //->
    </script>
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    You didn't show how the function is being called - a key part of the code. This should help:

    http://www.vortex-webdesign.com/help/3rdimageroll.htm
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    98
    Rep Power
    12
    There we go. I'm an idiot and forgot to put where the image was supposed to be. Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo