【发布时间】:2014-03-13 07:07:55
【问题描述】:
以下是文本滚动的javascript代码。能否请您扩展 javascript,以便当鼠标在文本上时滚动将停止,一旦鼠标没有文本,滚动将重新开始。提前致谢。
<html>
<head>
<style type="text/css">
#scroll{
position : absolute;
white-space : nowrap;
top : 0px;
left : 200px;
}
#oScroll{
margin : 0px;
padding : 0px;
position : relative;
width : 200px;
height : 20px;
overflow : hidden;
}
</style>
<script type="text/javascript">
function scroll(oid,iid){
this.oCont=document.getElementById(oid)
this.ele=document.getElementById(iid)
this.width=this.ele.clientWidth;
this.n=this.oCont.clientWidth;
this.move=function(){
this.ele.style.left=this.n+"px"
this.n--
if(this.n<(-this.width)){this.n=this.oCont.clientWidth}
}
}
var vScroll
function setup(){
vScroll=new scroll("oScroll","scroll");
setInterval("vScroll.move()",20)
}
onload=function(){setup()}
</script>
</head>
<body>
<div id="oScroll">
<div id="scroll">This is the scrolling text</div>
</div>
</body>
</html>
【问题讨论】:
-
你不能自己研究一下吗?然后,如果您的代码不起作用,您可以寻求帮助。
-
您是否正在寻找类似 marquee 之类的东西,它会在悬停时停止?
标签: javascript html css