asp 字幕连续滚动代码
1.文字也是可以连续滚动的
2.文字也是可以连续滚动的
3.文字也是可以连续滚动的
4.文字也是可以连续滚动的
5.文字也是可以连续滚动的
6.文字也是可以连续滚动的
var speed=40 //调整滚动速度
m0.innerHTML=mtext.innerHTML
function Marquee(){
if(m0.offsetTop-maq.scrollTop<=0)
maq.scrollTop-=mtext.offsetHeight
else{
maq.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
maq.onmouseover=function() {clearInterval(MyMar)}
maq.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
这个也是竖排的效果,就是比较简单!!
LZ,你的js代码写的有点乱哦,我在IE下调试发现了
function start(){
tm=setInterval('newScroll()',20);
}
和
function window.onload(){
simg1.innerHTML=simg.innerHTML
tm=setInterval('newScroll()',20)
}
中的newScroll写错了,应该是newsScroll。你可以直接复制我下面的代码覆盖掉你的代码,就可以直接运行了。温馨提醒lz书写代码时要记得缩进和语句结束后记得添加分号(;)
function newsScroll(){
if(scrollimg.parentNode.scrollLeft != (scrollimg.clientWidth/2)){
scrollimg.parentNode.scrollLeft++;
}
else{
scrollimg.parentNode.scrollLeft = 0;
}
}
var tm = null;
function window.onload(){
simg1.innerHTML = simg.innerHTML;
tm = setInterval('newsScroll()',20);
}
function stop(){
clearInterval(tm);
}
function start(){
tm = setInterval('newsScroll()',20);
}
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title><style type="text/css">
<!--
#marquee {
height: 120px;
width: 480px;
overflow: hidden;
}
#marquee .mi {
font-size: 12px;
width: 250px;
height: 110px;
border: 5px solid #666666;
margin-right: 10px;
margin-left: 10px;
}-->
</style>
<script type="text/javascript">
var marqueeInterval;
var cw,ch,mBody;
function marquee(){
try{
var A = arguments[0];
var O = document.getElementById(arguments[0])
var direction = arguments[1];
var delay = parseInt(arguments[2]);
var amount = parseInt(arguments[3]);
var isFirist = arguments[4];
var dw = O.offsetWidth
var dh = O.offsetHeight;
if(direction == "left" || direction == "right"){
clearInterval(marqueeInterval);
if(isFirist == true){
var mChild = document.all ? O.childNodes[0] : O.getElementsByTagName("div")[0];
cw = mChild.scrollWidth;
ch = mChild.scrollHeight;
//cw = document.all ? mChild.scrollWidth : mChild.clientWidth;
//ch = document.all ? mChild.scrollHeight : mChild.clientHeight;
mBody = mChild.innerHTML;
O.innerHTML = "";
var childNum = parseInt(dw/cw)+2;
var htmlString = "<table border=\"0\" width="+(childNum*cw)+" cellpadding=\"0\" cellspacing=\"0\"><tr>";
for(i = 0 ; i < childNum ; i++){
htmlString += "<td width=\""+cw+"\" height=\""+ch+"\"><div style=\"width:"+cw+"px height:"+ch+"px \">"+mBody+"</div></td>";
}
htmlString += "</tr></table>";
O.innerHTML = htmlString;
isFirist = false;
}
if(parseInt(O.scrollLeft) < parseInt(cw)){
O.scrollLeft = O.scrollLeft+amount;
}else{
O.scrollLeft = 0;
}
marqueeInterval = setInterval(function(){marquee(A,direction,delay,amount,isFirist)},delay)
}
}catch(e){
if (e.number == -2146827864)
alert("未选择要滚动的DIV")
else{
alert(e.description)
}
}
}
window.onload = function(){
marquee("marquee","left",50,1,true)
}
</script>
</head><body>
<div id="marquee" >
<div style="width: 240px;height: 18px;"><div class="mi">大家好,我是骄阳,这是一个无缝滚动效果</div></div>
</div>
<marquee direction="left" scrolldelay="10" scrollamount="1" width="480">大家好,我是骄阳,这是marquee的滚动效果</marquee>
</body>
</html>
由于时间问题,我只给你写一向左滚动效果但我还是建议你不要使用JS控制的无缝滚动,因为在WEB中setInterval和setTimeout都是很耗内存的这样就会降低你的页面执行速度如果你实在要用滚动效果的话,可以考虑用Flash代替
YYl里的 ? YY里的我有