想试验一下jascript事件属性的使用,我简写了下小代码可是运行时总提示两处缺少对象,不知道到底是什么原因造成的-!-希望大既能给于指点评判
<html>
<head>
<title>使用的事件属性</title>
</head>
<body>
<script>
imageA = new Image(50,50)
imageA.οnlοad=displayAlert
imageA.src="C:/Documents and Settings/Administrator/My Documents/My Pictures/19.gif" function displayAlert(theImage) {
if (theImage == null) {
alert('An image loaded')
}
else alert(theImage.name + ' has been loaded.')
}
</script> <img name="imageB" src="C:/Documents and Settings/Administrator/My Documents/My Pictures/19.gif" align="top"
onLoad="displayAlert(this)"><br> 关于事件适用对象.
<script>
var cycles=0
</script>
<img src="C:/Documents and Settings/Administrator/My Documents/My Pictures/m2.gif" boder=0 align="top"
onLoad="++cycles">
<input type="button" value="循环次数"
onClick="alert('The animation has looped ' + cycles + ' times.')">Why???
<script>
var whichImage=0
var maxImages=5 function changeAnimation(theImage) {
++whichImage
if (whichImage <= maxImages) {
var imageName="!anim" + whichImage + ".gif"
theImage.src=imageName
} else {
whichImage=-1
return
}
}
</script> <img name="changingAnimation" src="C:/Documents and Settings/Administrator/My Documents/My Pictures/28.gif" boder=0 align="top"
onLoad="changeAnimation(this)">
</body>