开发者

Picture in Document

开发者 https://www.devze.com 2023-01-02 01:15 出处:网络
<script type="text/javascript"> picture1 = new Image; picture1.src = "picture/loading.jpg";
<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:

 Mi开发者_开发知识库crosoft JScript runtime error: 'document.picture2' is null or not an object

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


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');
0

精彩评论

暂无评论...
验证码 换一张
取 消