当网面有滚动条时!如何做到,当鼠标下移,滚动条向下。当鼠标上移,滚动条向上。鼠标不动,滚动条不动。 ?

zhjian6 2005-06-22 08:16:39
分不够可以再加!
...全文
388 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
springwood 2005-06-23
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--

function test() {

if (event.clientY>document.all.dv.style.top.substring(0,document.all.dv.style.top.length-2)) {
document.all.dv.scrollTop =140;
} else {
document.all.dv.scrollTop =ddd;
}
}
//-->
</SCRIPT>
</HEAD>

<BODY onmousemove="test()">
<div id="dv" style="position:absolute;top:50;left:49;width:100;height:100;overflow-x:scroll;overflow-y:scroll">aaaaaaaaaaa<br>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<br>aaaaaaaaaaaaaaaaaaa<br>aaaaaaaaaaaaaaaaaaaa<br>aaaaaaaaaaaaaaaaa<br>aaaaaaaaaaaaaaaaaaaa<br>dsfsdfs</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
var ddd = document.all.dv.scrollTop;
//-->
</SCRIPT>
</BODY>
</HTML>
fantiny 2005-06-23
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Mouse Scroll</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
var mousestatus = false;
var cpos = 0;

function switchmode() {
mousestatus = !mousestatus;
if(mousestatus){
tt.style.display = '';
tt.style.left = 0;
cpos = mybody.clientHeight / 2 ;
tt.style.top = document.body.scrollTop + cpos ;
tt.style.left = document.body.clientWidth / 2;
//alert( document.body.scrollTop );
}
else{
tt.style.display='none';
}
}

function Conmousemove(){
if (mousestatus)
{
if(event.clientY > cpos){
//alert (event.clientY - cpos);
tt1.style.color = "#000000";
tt2.style.color = "#FF0000";
document.body.scrollTop = document.body.scrollTop + event.clientY - cpos;
tt.style.top = document.body.scrollTop + cpos ;
}
else{
//alert (cpos - event.clientY);
tt1.style.color = "#FF0000";
tt2.style.color = "#000000";
document.body.scrollTop = document.body.scrollTop + event.clientY - cpos;
tt.style.top = document.body.scrollTop + cpos ;
}
}
}
//-->
</SCRIPT>
</HEAD>

<BODY onmousemove="Conmousemove()" onmousedown="switchmode()" id="mybody">
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<P>this is a test page</P>
<table id="tt" style="position:absolute;width:0px;display:none;height:0px;color:#000000;z-index:99;">
<tr>
<td valign="middle" id="tt1">↑</td>
</tr>
<tr>
<td valign="middle" id="tt2">↓</td>
</tr>
</table>

</BODY>
</HTML>

鼠标左键点击切换滚动模式。
白夜花寒 2005-06-22
  • 打赏
  • 举报
回复
你先把一个检测鼠标的位置的函数写出来,我在你的基础上改就是了
zhjian6 2005-06-22
  • 打赏
  • 举报
回复
简单是简单,有没有实例啊?
白夜花寒 2005-06-22
  • 打赏
  • 举报
回复
这个很简单,就是你的整体下移动,你想的方法应该是给clientX赋值就是了。。。

87,916

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧