javascript'question,The code can't work.
This is the javascript code.<html>
<head>
<style>
.big{
height:0px;
position:relative;
top:50%;
left:50%;
float:left;
}
.small{
height:50px;
width:100px;
float:left;
position:relative;
top:50%;
left:50%;
border:2px solid #FFFFFF;
}
#bigPic{
height:300px;
width:300px;
position:relative;
top:50%;
left:50%;
}
#smallPic{
position:relative;
top:50%;
}
input{
height:50px;
width:50px;
position:relative;
top:50%;
left:50%;
float:left;
}
</style>
<script>
window.onload=function()
{
function startMove(obj,arrt,weizhi,speed)
{
clearInterval(obj.timer);
if (obj.currentStyle)
{
var dangqian = obj.currentStyle;
}
else
{
var dangqian = getComputedStyle(obj,false);
}
var speed = speed;
obj.timer = setInterval(function()
{
dangqian += speed;
if (dangqian >= weizhi)
{
if (obj.currentStyle)
{
obj.currentStyle = dangqian + "px";
}
else
{
getComputedStyle(obj,false) = dangqian + "px";
}
}
else
{
clearInterval(obj.timer);
}
},30)
}
var oBigImg = document.getElementById("bigPic").getElementsByTagName("img");
var oSmallImg = document.getElementById("smallPic").getElementsByTagName("img");
for (var x = 0;x < oSmallImg.length;x++)
{
oBigImg.timer = null;
oSmallImg.timer = null;
oBigImg.index = x;
oSmallImg.index = x;
oSmallImg.onmouseover = function()
{
if (oBigImg)
{
startMove(oBigImg,height,0,-5); Error!
}
else
{
startMove(oBigImg,height,300,5); Error!
}
}
}
}
</script>
</head>
<body>
<div id="bigPic">
<img src="Pictures/bg1.jpg" class="big" style="height=300px;"/>
<img src="Pictures/bg2.jpg" class="big" />
<img src="Pictures/bg3.jpg" class="big" />
<img src="Pictures/bg4.jpg" class="big" />
</div>
<div id="smallPic">
<input type="button" value="<" />
<img src="Pictures/bg1.jpg" class="small" />
<img src="Pictures/bg2.jpg" class="small" />
<img src="Pictures/bg3.jpg" class="small" />
<img src="Pictures/bg4.jpg" class="small" />
<input type="button" value=">">
</div>
</body>
</html> startMove(oBigImg,height,0,-5);
因为height变量还没有定义
页:
[1]