用 JavaScript 实现网页内容滚动效果
时间:2010-08-26 来源:洞幺人生
<!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>无标题文档</title>
</head>
<body>
<div id=demo style="OVERFLOW: hidden; HEIGHT:100px">
<div id=demo1>
<table cellSpacing=1 cellPadding=0 width="100%" border=0>
<tbody>
<tr>
<td><a href="#"><img height=80 src="" /></a></td>
<td><a href="#"><img height=80 src="" /></a></td>
<td><a href="#"><img height=80 src="" /></a></td>
</tr>
<tr>
<td>圆头绑带女鞋<p color=#ff0033>$ 265.00</p></td>
<td>圆头绑带女鞋<p color=#ff0033>$ 285.00</p></td>
<td>圆头绑带女鞋<p color=#ff0033>$ 295.00</p></td>
</tr>
</tbody>
</table>
</div>
<div id=demo2>
</div>
</div>
<script language="javascript" >
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee()
{
if(demo2.offsetTop-demo.scrollTop<=0)
demo.scrollTop-=demo1.offsetHeight
else{ demo.scrollTop++ }
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html>