(052)javascript_event_scrollTop

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5     <title>EVENT</title>
 6     <style type="text/css">
 7     </style>
 8     <script type="text/javascript">
 9 
10         document.onclick = function() {
11             //非Chrome下???
12             //alert(document.documentElement.scrollTop);
13 
14             //Chrome下???
15             //alert(document.body.scrollTop);
16 
17             var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
18             alert(scrollTop);
19         };
20 
21     </script>
22 </head>
23 
24 <body style="height:2000px;">
25 
26 
27 </body>
28 </html>

 

posted @ 2014-03-23 11:50  雪中飞雁  阅读(103)  评论(0)    收藏  举报