标题:帮忙找错
只看楼主
lzyren2008
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2007-8-12
 问题点数:0 回复次数:2 
帮忙找错
<html>
 <head>
     <title>picmove</title>
     <META http-equiv="content-type" CONTENT="text/html;charset=gb2312">
     <META NAME="Author" CONTENT="CZH;czh44@
     <META NAME="Generator" CONTENT="EditPlus">
 </head>
 <script language="javascript">
     theX=0;   <!--//表示鼠标位置的x坐标-->
     theY=0;   <!--//表示鼠标位置的y坐标-->
     to=0;     <!--//表示图片层的top属性-->
     le=0;    <!--//表示图片层的left属性-->
     step=9;   <!--//图片移动的“单步速率“-->
     inter=100;  <!-- //setTimeout()方法的周期-->
     ifNN4=(navigator.appName="Netscape"&&parseInt(navigator.appVersion)==4);
     ifNN6=(navigator.appName=="Netscape"&&parseInt(navigator.appVersion)==5);  <!--//Netscape Navigator 6浏览器的appVersion属性中提供的数字为5-->
     function movePic()
     {
        var layImg=(ifNN4)?document.layImage:document.getElementById("layImg").style;/////错误行
        if(theX-le>-30||theX-le<-40)
        {
          le+=step*((theX-le>-30)?1:-1);
          layImg.left=le;
        }
        if(theY-to>80||theY-to<70)
            {
                to+=step*((theY-to>80)?1:-1);
                layImg.top=to;
           }
           setTimeout('movePic()',inter);
     }
     
     function getPos(e)
     <!--该函数获取当前鼠标的位置信息-->
     {
         if(ifNN4||ifNN6)
         {
             theX=e.pageX;
             they=e.pageY;
         }
         else
         {
             theX=document.body.scrollLeft+event.clientX;
             theY=document.body.scrollTop+event.clientY;
         }
     }
     if(ifNN4||ifNN6)
     document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove=getPos();
</script>
<body onload="movePic()">
    <div id="layImg" style="position:absolute;z-index:10">
        <img src="pic.jpg" alt="study in Canada">    
    </div>
</body>
</html>

这是个跟随鼠标运动的图片的程序,如上所示,调试时“错误行”显示有问题,请大家帮忙看看到底是什么问题了,是否就是这行有错误。
搜索更多相关主题的帖子: 123 
2008-12-02 23:50
徐强
Rank: 2
等 级:新手上路
威 望:3
帖 子:72
专家分:0
注 册:2007-3-30
得分:0 
var ifNN4=(navigator.appName="Netscape"&&parseInt(navigator.appVersion)==4);
  var  ifNN6=(navigator.appName=="Netscape"&&parseInt(navigator.appVersion)==5);
两个定义的bool变量前加var就可以了,但好像图片移动有问题    跑到上边就没了
2008-12-03 09:46
lzyren2008
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2007-8-12
得分:0 
对啊,也不是咋会事,新手,不懂问题在哪!请人指教!
2008-12-03 10:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-247475-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.288518 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved