鱼C论坛

 找回密码
 立即注册
查看: 3494|回复: 1

[已解决]javascript'question,The code can't work.

[复制链接]
发表于 2017-7-8 21:36:53 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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>
最佳答案
2017-9-7 10:33:13
startMove(oBigImg[this],height,0,-5);
因为height变量还没有定义
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-9-7 10:33:13 | 显示全部楼层    本楼为最佳答案   
startMove(oBigImg[this],height,0,-5);
因为height变量还没有定义
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-6-29 09:18

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表