<!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.οnscrοll=scrollBottomOrTop;
</script>
</body>
</html>