views:

39

answers:

1
<script type="text/javascript">
    picture1 = new Image;
    picture1.src = "picture/loading.jpg";
    picture2 = new Image;
    picture2.src = "picture/loader.jpg";
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="page5.html" onmouseover="document.picture2.src=picture2.src" 
                         onmouseout="document.picture1.src=picture1.src">
       <img name="picture" src="picture/loading.jpg" alt="image" />
    </a>

    </div>
    </form>
</body>

this is my code when i debug this it showing:

 Microsoft JScript runtime error: 'document.picture2' is null or not an object

But i already asign value to the 'document.picture2'

+1  A: 

The global object is window not document. Therefore you may want to use window.picture2.src instead of document.picture2.src.

In addition, you should probably give a unique id to your elements and reference them using document.getElementById():

<img id="picture1" src="picture/loading.jpg" alt="image" />

...is referenced using:

document.getElementById('picture1');
Daniel Vassallo
no i m not referencing at all
picnic4u
i got it i done mistake the correct onmouseover and onmouseout is document.picture.src=picture1.src
picnic4u