62,046
社区成员
发帖
与我相关
我的任务
分享
var winScroll = Math.round(document.documentElement.scrollTop) || Math.round(document.body.scrollTop);
var loadFlag = Math.round(document.body.offsetHeight - (1.2 * (document.documentElement.clientHeight)));
if (winScroll >= loadFlag && isLoading == false) {}
<a id="gotopbtn" style="position:fixed;width:12px;bottom:95px;right:195px !important;display:none;cursor:pointer; _position: absolute;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight - this.offsetHeight)); _background:none; display:none;)">返回顶部</a>
<script type="text/javascript">goTopEx();</script>
<script type="text/javascript">
function goTopEx() {
var obj = document.getElementById("gotopbtn");
function getScrollTop() {
return document.documentElement.scrollTop || document.body.scrollTop;
}
function setScrollTop(value) {
if (document.documentElement.scrollTop) {
document.documentElement.scrollTop = value;
} else {
document.body.scrollTop = value;
}
}
obj.onclick = function () {
var goTop = setInterval(scrollMove, 1);
function scrollMove() {
setScrollTop(getScrollTop() / 1.1);
if (getScrollTop() < 1) clearInterval(goTop);
}
}
//让返回顶部标签,始终停在footer 之前!
var btmHeight = (-[1, ]) ? 340 : 350;
window.onscroll = function () {
getScrollTop() > 0 ? obj.style.display = "" : obj.style.display = "none";
obj.style.bottom = 85 + "px";
if (getDisFromBottom() <= btmHeight) {
obj.style.bottom = getDisFromBottom() + "px";
obj.style.top = "auto";
}
}
function getDisFromBottom() {
var dis = getScrollTop() + getClientHeight() + btmHeight - getScrollHeight();
return dis > 85 ? dis : 85;
}
function getScrollHeight() {
return getDocEle().scrollHeight;
}
function getClientHeight() {
return getDocEle().clientHeight;
}
function getDocEle() {
return document.compatMode == 'CSS1Compat' ? document.documentElement : document.body;
}
}
</script>