html上面带个单纯的 js 不间断滚动。
<div id="marquees">
图片图片。
</div>
<div id="templayer" style="position: absolute; left: 0; top: 0; visibility: hidden"></div>
<script language="JavaScript">
marqueesWidth=850; //控制滚动宽度
with(marquees){
style.height=176; //控制高度
style.width=marqueesWidth;
style.overflowX="hidden";
style.overflowY="visible";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
preLeft=0; currentLeft=0; stopscroll=false;
function init(){
templayer.innerHTML="";
while(templayer.offsetWidth<marqueesWidth){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML+=templayer.innerHTML;
setInterval("scrollLeft()",20); //这里控制速度
}init();
function scrollLeft(){
if(stopscroll==true) return;
preLeft=marquees.scrollLeft;
marquees.scrollLeft+=1;
if(preLeft==marquees.scrollLeft){
marquees.scrollLeft=templayer.offsetWidth-marqueesWidth+1;
}
}
</script>
单独测试滚动代码木有问题。
但是把它 粘到 想要效果的html中。cup 一路飙升
访问时为出现 xxx.html 发生违例共享
好奇怪?
是js 写的不兼容?还是 html 有问题? 高手指点啊