$(window).scroll(function(){
var _wrapperHeight = window.innerHeight || document.documentElement.clientHeight
|| document.body.clientHeight;
var _contentHeight = Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
//var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop || window.scrollY;
if ($(window).scrollTop()/(_contentHeight-_wrapperHeight) >= 0.8) {
var flag = localStorage.getItem('shown-register-popup');
if (!flag) {
$('#first-access-register-tips').modal('show');
localStorage.setItem('shown-register-popup', 'true');
}
}
});
刚开始用的是原生的js:
document.addEventListener('scroll',function(){})
在移动端scroll不能使用。
然后用了touchmove替换scroll:
document.addEventListener('scroll',function(){})
然后也是bug一堆,要滑动到最下面,再往上滑动蔡有用。
最后用的是jquery的 :
$(window).scroll(function())