Js滚动

本文介绍了一种使用JavaScript实现网页内容水平滚动的方法。通过监听鼠标事件来调整网页的滚动位置,实现了网页内容的平滑左右滚动效果。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<SCRIPT language="javascript">
function movstar(a,time)
{
 movx=setInterval("mov("+a+")",10);
}

function movover()
{
 clearInterval(movx);
}

function mov(a)
{
 scrollx=new_date.document.body.scrollLeft;
 scrolly=new_date.document.body.scrollTop;
 scrollx=scrollx+a;
 new_date.window.scroll(scrollx,scrolly);
}

function o_down(theobject)
{
 object=theobject;
}

function o_up(theobject)
{
 object=theobject;
}

</SCRIPT>
</head>
<body>
<table width="100" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="29" bgcolor="#99BECD">
 <img src="http://www.bdtydq.cn/images/leftgun-2.jpg" alt="向左移动" onMouseDown="movover();movstar(-3,2)" onMouseUp="movover();movstar(-1,20)" onMouseOver="movstar(-1,10);o_down(this)" onMouseOut="movover();o_up(this)"></td>
    <td width="700" align="center" bgcolor="#99BECD"><IFRAME marginWidth=0 name="new_date" marginHeight=0 src="page.html" width="700" height="140" frameBorder=0 scrolling=auto></IFRAME></td>
    <td width="29" align="right" bgcolor="#99BECD">
 <img src="http://www.bdtydq.cn/images/rightgun-2.jpg" alt="向右移动" onMouseDown="movover();movstar(3,2)" onMouseUp="movover();movstar(1,20)" onMouseOver="movstar(1,10);o_down(this) " onMouseOut="movover();o_up(this) "></td>
  </tr>
</table>
</body>
</html>

转载于:https://www.cnblogs.com/hanwater/archive/2010/01/30/1660019.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值