赞助连接

赞助连接

阅 读 文 章

晕了,后一句比前一句先运行

[来源:网上转载 (CSDN转载) | 作者:网友(gaochao79) | 时间:2008-09-13 | 浏览:人次 ]

<html   xmlns="http://www.w3.org/1999/xhtml">  
  <head>  
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312"   />  
  <title>鼠标替换测试</title>  
  <script   language="javascript">  
  var   cursorarr=new   Array()  
  function   setcursor(){  
  var   j=0;  
  for(i=0;i<document.all.length;i++)   {    
  if(document.all[i].tagName.toLowerCase()=="div"||document.all[i].tagName.toLowerCase()=="a"||document.all[i].tagName.toLowerCase()=="span"||document.all[i].tagName.toLowerCase()=="body"||document.all[i].tagName.toLowerCase()=="input"){  
  cursorarr[j]=document.all[i].currentStyle.cursor;  
  alert(cursorarr[j]);  
  j++;  
  document.all[i].style.cursor='/images/cursor.ani';  
  }  
   
  }  
  }  
   
  function   resetcursor(){  
  var   j=0;  
  for(i=0;i<document.all.length;i++)   {    
  if(document.all[i].tagName.toLowerCase()=="div"||document.all[i].tagName.toLowerCase()=="a"||document.all[i].tagName.toLowerCase()=="span"||document.all[i].tagName.toLowerCase()=="body"||document.all[i].tagName.toLowerCase()=="input"){  
  document.all[i].style.cursor=cursorarr[j++];  
  }  
  }  
  }  
  </script>  
  </head>  
   
  <body>  
  <p   id="1">  
  <a   href=http://topic.csdn.net/t/20061124/15/"#";   onclick="javascript:setcursor();">auto</a>  
          <a   href=http://topic.csdn.net/t/20061124/15/"#";   onclick="javascript:resetcursor();">crosshair</a>  
          <a   href=http://topic.csdn.net/t/20061124/15/"#";   style="cursor:   default">default</a>  
          <a   href=http://topic.csdn.net/t/20061124/15/"#";   style="cursor:   pointer">pointer   </a>  
  </p>  
  <span   style="cursor:pointer">aaa</span>  
  <span>dsafdsafsfda</span>  
  </body>  
  </html>  
  ---------------------------  
  上面这个页面是一个测试替换鼠标指针样式的页面,里面函数setcursor()中的alert(cursorarr[j]);这行,第一次运行到<span>dsafdsafsfda</span>标签的时候弹出的提示就是url(/images/cursor.ani)  
  注释掉document.all[i].style.cursor='/images/cursor.ani';  
  则顺利弹出提示auto  
  好像是下面这句document.all[i].style.cursor='/images/cursor.ani';提前运行了  
  请高手指教  
   
 
script   language="javascript">  
   
  var   isFinished   =   false;  
   
  var   cursorarr=new   Array()  
  function   setcursor(){  
  var   j=0;  
  for(i=0;i<document.all.length;i++)   {    
  if(document.all[i].tagName.toLowerCase()=="div"||document.all[i].tagName.toLowerCase()=="a"||document.all[i].tagName.toLowerCase()=="span"||document.all[i].tagName.toLowerCase()=="body"||document.all[i].tagName.toLowerCase()=="input"){  
  cursorarr[j]=document.all[i].currentStyle.cursor;  
  alert(cursorarr[j]);  
  j++;  
  document.all[i].style.cursor='/images/cursor.ani';  
  }  
   
  }  
   
                    isFinished   =   true;  
   
  }  
   
  function   resetcursor(){  
  if(isFinished)  
  {  
  var   j=0;  
  for(i=0;i<document.all.length;i++)   {    
  if(document.all[i].tagName.toLowerCase()=="div"||document.all[i].tagName.toLowerCase()=="a"||document.all[i].tagName.toLowerCase()=="span"||document.all[i].tagName.toLowerCase()=="body"||document.all[i].tagName.toLowerCase()=="input"){  
  document.all[i].style.cursor=cursorarr[j++];  
  }  
  }  
  }  
  isFinished   =   false;  
  }  
  </script>  
 

解决了   body的问题   偶真笨
论坛热门帖子: [lch203] 写得蛮好的linux学习笔记(10-21)
[黑马制造] 学习java的30个目标(10-19)
[笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19)
[udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18)
[沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18)
TAG标签: 运行 document.all .tagName.toLowerCase cursorarr var

最新评论 共有0位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表

网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.chmhome.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.