|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
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[arrt])
- {
- var dangqian = obj.currentStyle[arrt];
- }
- else
- {
- var dangqian = getComputedStyle(obj,false)[arrt];
- }
- var speed = speed;
- obj.timer = setInterval(function()
- {
- dangqian += speed;
- if (dangqian >= weizhi)
- {
- if (obj.currentStyle[arrt])
- {
- obj.currentStyle[arrt] = dangqian + "px";
- }
- else
- {
- getComputedStyle(obj,false)[arrt] = 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[x].timer = null;
- oSmallImg[x].timer = null;
- oBigImg[x].index = x;
- oSmallImg[x].index = x;
- oSmallImg[x].onmouseover = function()
- {
- if (oBigImg[this])
- {
- startMove(oBigImg[this],height,0,-5); Error!
- }
- else
- {
- startMove(oBigImg[this],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[this],height,0,-5);
因为height变量还没有定义
|
|