js向左滚动的文字

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>   <title>向左滚动的文字特效JS代码 </title>      

</head>

<body>

<div id="demo" style="overflow:hidden;height:24px; line-height:24px;width:600px; border:1px solid #666; white-space:nowrap;">

<div id="demo1">   基于jquery特效,jquery弹出层效果,js特效代码大全,JS广告代码,导航菜单代码,下拉菜单代码和jquery焦点图片代码。

</div>

<div id="demo2"></div>

</div>

<script type="text/javascript"> var speed=40;//数值越大,速度越慢

var demo2=document.getElementById("demo2");

var demo1=document.getElementById("demo1");

var demo=document.getElementById("demo");

function MarqueeLeft()

{ if(demo2.offsetWidth-demo.scrollLeft<=0) demo.scrollLeft-=demo1.offsetWidth else{ demo.scrollLeft++ } }

var MyMar=setInterval(MarqueeLeft,speed); demo.onmouseover=function() {clearInterval(MyMar);} demo.onmouseout=function() {MyMar=setInterval(MarqueeLeft,speed);} </script>  

  </body> </html>

posted @ 2013-04-10 16:51  盛开的雨季  阅读(7636)  评论(0编辑  收藏  举报