- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <style type="text/css">
- .scrolldiv{
- width: 500px;
- height: 400px;
- margin: 1000px auto 100px auto;
- background: #f00;
- }
- </style>
- </head>
- <body>
- <div class="scrolldiv"></div>
-
-
- <script type="text/javascript">
- function scrollBottomOrTop(){
- var clients=window.innerHeight || document.documentElement.clientHeight||document.body.clientHeight;
- var scrollTop=document.body.scrollTop;
- var wholeHeight=document.body.scrollHeight;
- if(clients+scrollTop>=wholeHeight){
- alert('我到底部了');
- }
- if(scrollTop==0){
- alert('我到顶部了');
- }
- }
- window.onscroll=scrollBottomOrTop;
- </script>
- </body>
- </html>
posted @
2017-10-18 21:00
逗比煎饼侠
阅读(
1174)
评论()
编辑
收藏
举报