<html>
<head>
<title>OnScroll Example</title>
<script type="text/javascript">document.onscroll = function() {
console.info(arguments);
}</script>
</head>
<body>
<P style="position:absolute;top:30; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:60; left:900">Try scrolling this window.</p>
<P style="position:absolute;top:90; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:120; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:150; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:180; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:210; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:240; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:270; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:300; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:330; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:360; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:390; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:420; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:450; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:480; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:510; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:540; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:570; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:600; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:630; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:660; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:690; left:10">Try scrolling this window.</p> </body>
</html>在onscroll里怎么能判断出这次滚动是水平还是垂直
<head>
<title>OnScroll Example</title>
<script type="text/javascript">document.onscroll = function() {
console.info(arguments);
}</script>
</head>
<body>
<P style="position:absolute;top:30; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:60; left:900">Try scrolling this window.</p>
<P style="position:absolute;top:90; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:120; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:150; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:180; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:210; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:240; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:270; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:300; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:330; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:360; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:390; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:420; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:450; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:480; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:510; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:540; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:570; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:600; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:630; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:660; left:10">Try scrolling this window.</p>
<P style="position:absolute;top:690; left:10">Try scrolling this window.</p> </body>
</html>在onscroll里怎么能判断出这次滚动是水平还是垂直
var l=document.documentElement.scrollLeft || document.body.scrollLeft;document.onscroll = function() {
var t1=document.documentElement.scrollTop || document.body.scrollTop;
var l1=document.documentElement.scrollLeft || document.body.scrollLeft;
if(t1!=t)
{
t=t1;
alert("垂直滚动");
}
if(l1!=l)
{
l=l1;
alert("水平滚动");
}
}