function show(){
var showId = document.getElementById("target");
var client = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var targetTop = showId.getBoundingClientRect().top;
if(targetTop <= client){
//图片加载
}
}
window.onscroll = show();
function scrollBottomOrTop(){
var client = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var scrollTop = document.body.scrollTop;
var wholeHeight = document.body.scrollHeight;
if(client+scrollTop >= wholeHeight){
alert("已经滚动到底部");
//ajax加载
}
if(scrollTop==0){
alert("已经滚动到顶部");
}
}
window.onscroll = scrollBottomOrTop();
var divScroll = document.getElementById("target");
function DivScroll(){
var wholeHeight = divScroll.scrollHeight;
var scrollTop = divScroll.scrollTop;
var divHeight = divScroll.clientHeight;
if(scrollTop+divHeight >= wholeHeight){
alert("DIV滚动到底部了");
}
if(scrollTop==0){
alert("DIV滚动到顶部了");
}
}
divScroll.onscroll = DivScroll;