JS 文字向上滚动代码
<html> <HEAD> <TITLE>自动向上滚动的文本,鼠标放上去就停止--建站学-www.jzxue.com</TITLE> <META content="text/html; charset=gb2312" http-equiv=Content-Type> <STYLE type=text/css> #demo a { width:100%; overflow:hidden; font:12px/16px tahoma; display:block; text-decoration:none; margin:2px; color:#4a551c; padding-left:2px; text-align:left; } #demo a:hover { color:#ff6600; } </STYLE> </HEAD> <body> <div id="demo" style="overflow:hidden;height:132px;width:400px; border:1px solid #dde5bc;"> <div id="demo1"> <a href="#">该特效代码完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">建站学收集整理,希望大家多提意见</a> <a href="#">该特效代码完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">建站学收集整理,希望大家多提意见</a> <a href="#">该特效代码完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">建站学收集整理,希望大家多提意见</a> <a href="#">该特效代码完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">建站学收集整理,希望大家多提意见</a> <a href="#">该特效代码完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">建站学收集整理,希望大家多提意见</a> <a href="#">该特效代码完全兼容IE, FF, Opera, 其它的还未经测试……</a> <a href="#">建站学收集整理,希望大家多提意见</a> </div> <div id="demo2"></div> </div> <script> var speed=40 var demo=document.getElementById("demo"); var demo2=document.getElementById("demo2"); var demo1=document.getElementById("demo1"); demo2.innerHTML=demo1.innerHTML function Marquee(){ if(demo2.offsetTop-demo.scrollTop<=0) demo.scrollTop-=demo1.offsetHeight else{ demo.scrollTop++ } } var MyMar=setInterval(Marquee,speed) demo.onmouseover=function() {clearInterval(MyMar)} demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)} </script> </body> </html>