1、使用JavaScript制作一个跑马灯。
2个回答
展开全部
<div id="demo" style="width:137px; height:46px; overflow:hidden;">
<div style=" height:92px; width:137px">
<span id="demo1"><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-zhidao.gif" width="137" height="46" /></span>
<span id="demo2"></span>
</div>
</div>
<script>
var demo=document.getElementById("demo");
var demo1=document.getElementById("demo1");
var demo2=document.getElementById("demo2");
demo2.innerHTML=demo1.innerHTML;
var time_=30;
function marquee_()
{
if(demo.scrollTop>=demo1.scrollHeight)
demo.scrollTop=0;
else
demo.scrollTop++;
}
var mar=setInterval(marquee_,time_);
demo.onmouseover=function(){clearInterval(mar)};
demo.onmouseout=function(){mar=setInterval(marquee_,time_)}
</script>
<div style=" height:92px; width:137px">
<span id="demo1"><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-zhidao.gif" width="137" height="46" /></span>
<span id="demo2"></span>
</div>
</div>
<script>
var demo=document.getElementById("demo");
var demo1=document.getElementById("demo1");
var demo2=document.getElementById("demo2");
demo2.innerHTML=demo1.innerHTML;
var time_=30;
function marquee_()
{
if(demo.scrollTop>=demo1.scrollHeight)
demo.scrollTop=0;
else
demo.scrollTop++;
}
var mar=setInterval(marquee_,time_);
demo.onmouseover=function(){clearInterval(mar)};
demo.onmouseout=function(){mar=setInterval(marquee_,time_)}
</script>
展开全部
<html>
<head>
<script Language="JavaScript">
var msg="这是一个跑马灯效果的JavaScript文档";
var interval = 100;
var spacelen = 120;
var space10=" ";
var seq=0;
function Scroll() {
len = msg.length;
window.status = msg.substring(0, seq+1);
seq++;
if ( seq >= len ) {
seq = spacelen;
window.setTimeout("Scroll2();", interval );
}
else
window.setTimeout("Scroll();", interval );
}
function Scroll2() {
var out="";
for (i=1; i<=spacelen/space10.length; i++) out +=
space10;
out = out + msg;
len=out.length;
window.status=out.substring(seq, len);
seq++;
if ( seq >= len ) { seq = 0; };
window.setTimeout("Scroll2();", interval );
}
</script>
<body>
</body>
</html>
<head>
<script Language="JavaScript">
var msg="这是一个跑马灯效果的JavaScript文档";
var interval = 100;
var spacelen = 120;
var space10=" ";
var seq=0;
function Scroll() {
len = msg.length;
window.status = msg.substring(0, seq+1);
seq++;
if ( seq >= len ) {
seq = spacelen;
window.setTimeout("Scroll2();", interval );
}
else
window.setTimeout("Scroll();", interval );
}
function Scroll2() {
var out="";
for (i=1; i<=spacelen/space10.length; i++) out +=
space10;
out = out + msg;
len=out.length;
window.status=out.substring(seq, len);
seq++;
if ( seq >= len ) { seq = 0; };
window.setTimeout("Scroll2();", interval );
}
</script>
<body>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询