Re: 卷屏,滚动代码
[code]<html>
<head>
<style type="text/css">
<!--
.test {
font-size: 12px;
line-height: normal;
text-decoration: none;
}
-->
</style>
<head>
<body>
<div id="layer1" style="overflow-y:hidden;width:50;">
<div id="layer2">
<table width="200" height="100" border="0" align="center" cellpadding="0" cellspacing="0" class="test">
<tr>
<td width="200" height="100" valign="top" bgcolor="#FFFFFF" class="nav1style style46">
无间断卷屏测试,
</td>
</tr>
</table>
</div>
<div id="layer3"></div>
<script language="javascript">
var layerHeight = 100; // 定义滚动区域的高度.
var iFrame = 1; // 定义每帧移动的象素.
var iFrequency = 50; // 定义帧频率.
var timer; // 定义时间句柄.
if(document.getElementById("layer2").offsetHeight >= layerHeight)
document.getElementById("layer1").style.height = layerHeight;
else
document.getElementById("layer1").style.height = document.getElementById("layer2").offsetHeight;
document.getElementById("layer3").innerHTML = document.getElementById("layer2").innerHTML;
function move(){
if(document.getElementById("layer1").scrollTop >= document.getElementById("layer2").offsetHeight){
document.getElementById("layer1").scrollTop -= (document.getElementById("layer2").offsetHeight - iFrame);
}
else {
document.getElementById("layer1").scrollTop += iFrame;
}
}
timer = setInterval("move()",iFrequency);
document.getElementById("layer1").onmouseover=function() {clearInterval(timer);}
document.getElementById("layer1").onmouseout=function() {timer=setInterval("move()",iFrequency);}
</script>
</body>
</html>[/code]