<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>建站代码-上下翻滚JS</title>
</head>
<body>
<div id="adsfar" style="background:#FF0000">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF">11111111111111111</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">22222222222222222</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">33333333333333333</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">44444444444444444444444444</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">55555555555555555555555</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">66666666666666666666666666666</td>
</tr>
</table>
</div>
<script type="text/javascript">
marque(400,28,"adsfar")
var scrollId;
var stopscroll;
var stoptime;
var preTop;
var leftElem;
var currentTop;
var marqueesHeight;
function marque(width,height,marqueId,marqueTagName){
try{
marqueesHeight = height;
stopscroll = false;
scrollId = document.getElementById(marqueId);
with(scrollId){
style.width = width + "px";
style.height = marqueesHeight + "px";
style.overflow = 'hidden';
noWrap = true;
}
scrollId.onmouseover = new Function('stopscroll = true');
scrollId.onmouseout = new Function('stopscroll = false');
preTop = 0;
currentTop = 0;
stoptime = 0;
alert( scrollId.scrollHeight);
if(height < scrollId.scrollHeight){
leftElem = document.getElementById(marqueId);
//alert(leftElem.cloneNode(true));
scrollId.appendChild(leftElem.cloneNode(true)); //cloneNode(true) 如果这个布尔参数设置为 true,被克隆的节点会复制原始节点的所有子节点。
init_srolltext();
}
}catch(e) {}
}
function init_srolltext(){
scrollId.scrollTop = 0;
setInterval('scrollUp()', 18);
}
function scrollUp(){
if(stopscroll) return;
currentTop += 1;
if(currentTop == marqueesHeight+1) {
stoptime += 1;
currentTop -= 1;
if(stoptime == (marqueesHeight)*1) {//??
currentTop = 0;
stoptime = 0;
}
}else{
preTop = scrollId.scrollTop; //网页被卷去的高
//alert(preTop);
scrollId.scrollTop += 1;
if(preTop == scrollId.scrollTop){
scrollId.scrollTop = marqueesHeight;
scrollId.scrollTop += 1;
}
}
}
</script>
</body>
</html>