兼容FF&IE的滚动代码
[ 2007/01/04 23:27 | by ipaddr ]
[code]
<table width=250 border=0 bgcolor=F6F6F6 style="margin-top:15;border:1px solid #F2F2F2" height="150">
<tr>
<td height="100px">
<div id="scrollcont" style="overflow:hidden;height:100px;" onmouseover="scrolling=1" onmouseout="scrolling=0">
<div id="scrollcont1">
My Name is tomzhou! <br>
Hello,ipaddr<br>
Hello,bcomcn <br>
My Name is tomzhou2! <br>
Hello,ipaddr2<br>
Hello,bcomcn2<br>
</div>
<div id="scrollcont2"></div>
</div>
</td>
</tr>
</table>
<script>
var scrolling=0;
var t=scrollcont.scrollTop;
scrollcont2.innerHTML=scrollcont1.innerHTML;
function scrollShow()
{
if (scrolling==1) return;
if (scrollcont2.offsetTop-scrollcont.scrollTop<=0)
scrollcont.scrollTop-=scrollcont1.offsetHeight;
else
scrollcont.scrollTop++;
}
setInterval(scrollShow,50);
</script>
[/code]
其中,100px是滚动区域的高度,宽度由scrollcont的外面容器决定,setInterval里面的50决定滚动的速度。
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<table width=250 border=0 bgcolor=F6F6F6 style="margin-top:15;border:1px solid #F2F2F2" height="150">
<tr>
<td height="100px">
<div id="scrollcont" style="overflow:hidden;height:100px;" onmouseover="scrolling=1" onmouseout="scrolling=0">
<div id="scrollcont1">
My Name is tomzhou! <br>
Hello,ipaddr<br>
Hello,bcomcn <br>
My Name is tomzhou2! <br>
Hello,ipaddr2<br>
Hello,bcomcn2<br>
</div>
<div id="scrollcont2"></div>
</div>
</td>
</tr>
</table>
<script>
var scrolling=0;
var t=scrollcont.scrollTop;
scrollcont2.innerHTML=scrollcont1.innerHTML;
function scrollShow()
{
if (scrolling==1) return;
if (scrollcont2.offsetTop-scrollcont.scrollTop<=0)
scrollcont.scrollTop-=scrollcont1.offsetHeight;
else
scrollcont.scrollTop++;
}
setInterval(scrollShow,50);
</script>
[/code]
其中,100px是滚动区域的高度,宽度由scrollcont的外面容器决定,setInterval里面的50决定滚动的速度。
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>