刷新页面 回到顶部
window.onbeforeunload = function () {
window.scrollTo(0, 0);
}
距离顶部多少距离
$('body,html').scrollTop(180);
$('html,body').animate({
scrollTop:$("#collapse-payment-address .panel-body").offset().top - 100
}, 1000);
遮罩层
var msg = '<div class="mask-layer-hui" style="min-width: 100px;background-color: #000;filter: alpha(opacity=60);background-color: rgba(0,0,0,.6);color: #fff;border: none;box-shadow: none;border-radius: 2px;position: fixed;z-index: 19891018;top: 50%;left: 25%;right: 25%;width: 50%">';
msg += '<div class="mask-layer-content" style="padding: 12px 25px;text-align: center;position: relative;line-height: 24px;word-break: break-all;overflow: hidden;font-size: 14px;overflow-x: hidden;overflow-y: auto;">'+content+'</div>';
msg += '</div>';
$("#checkout-checkout").append(msg);
$(".mask-layer-hui").fadeIn().delay(3000).fadeOut('slow','swing',function () {
$(".mask-layer-hui").remove();
});
var common=function(){};
Common.prototype={
onScrollEvent:function(){
$(window).scroll(function(){
if(common.isPageBottom()){
console.log('滚动条到达页面的底部')
}
});
},
isPageBottom:function(){
var winH = $(window).height(); //页面可视区域高度
var pageH = $(document.body).height();//页面的高度
var scrollT = $(window).scrollTop(); //滚动条top
//这里做一个计算距离底部还差多少,下边跟0.02比就是,滚动条的高度小于页面可视区域高度的的2%
var aa = (pageH-winH-scrollT)/winH;
//这里做比较当他小于0.02的时候我就认为他已经到底部了,为再次请求数据做一个缓冲,提高浏览页面的流畅度
if(aa<0.02){
return true;
}
return false;
},
}