<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>
这是我调试时的代码,显示:
Microsoft JScript runtime error: 'document.picture2' is null or not an object
但我已经将'value.picture2'
赋予了价值答案 0 :(得分:1)
全局对象为window
而非document
。因此,您可能希望使用window.picture2.src
代替document.picture2.src
。
此外,您应该为元素添加唯一的id
并使用document.getElementById()
引用它们:
<img id="picture1" src="picture/loading.jpg" alt="image" />
...使用:
引用document.getElementById('picture1');