开发者

JavaScript function compatible problem needs your help

开发者 https://www.devze.com 2022-12-14 11:57 出处:网络
<ul id=\"MarqueePro2\"></ul> </ul> <script> var speed=60; var MarqueePro=document.getElementById(\"MarqueePro\");
<ul id="MarqueePro2"></ul>
 </ul>
 <script>
     var speed=60;
     var MarqueePro=document.getElementById("MarqueePro");
     var MarqueePro2=document.getElementById("MarqueePro2");
     var MarqueePro1=document.getElementById("MarqueePro1");
     MarqueePro2.innerHTML=MarqueePro1.innerHTML;
 function Marquee()
 {
     if(MarqueePro2.offsetTop-MarqueePro.scrollTop<=0)
     {
         MarqueePro.scrollTop-=MarqueePro1.offsetHeight;
     }
     else
     {
         MarqueePro.scrollTop++;
     }
 }
     var MyMar=setInterval(Marquee,speed);
     MarqueePro.onmouseover=function() {clearInterval(MyMar)}
     MarqueePro.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
 </script>

appers shake under I开发者_如何转开发E browser.how to solve the problem? and thx very much!


scrollTop behaviour in IE is extremely dodgy. Two things can affect it:

1) The document type - you have to get the right one - there appears to be some issues with transitional and loose DTDs.

2) Whether or not there is overflow set on the container.

See http://forums.digitalpoint.com/showthread.php?t=11965. It presents a solution to both issues of scrollTop in IE.

(At the risk of enacting a stackoverflow cliche, you might want to consider using a framework such as jQuery, which will take a lot of such annoyances out of the equation).


I'm not sure what your script intends to do, but for Javascript effects, check out the frameworks:

JQUery

Prototype / Scriptaculous

Mootools

they have worked out most cross browser issues and are very easy to use.


You may want to set speed to a higher number.

The second argument to setInterval is the delay in milliseconds. 60 milliseconds is quite fast; 50 milliseconds is 1/20th of a second.

Maybe try 100 or 200 to see if things improve?

0

精彩评论

暂无评论...
验证码 换一张
取 消