87,993
社区成员
发帖
与我相关
我的任务
分享<meta http-equiv="Cache-Control" content="no-transform " />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="applicable-device" content="pc,mobile">
<meta name="renderer" content="ie-comp">
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
var shortid = "xx", articleid = "xx", next_chapterid = "xx";//xx填写你自己的ID
//下一章的url判断
if (next_chapterid !== "") {//判断是否有下一章
var person = {
tid: shortid,
eid: articleid,
nextid: next_chapterid,
Namepageid: function() {
return "/" + this.tid + "/" + this.eid + "/" + this.nextid + ".html"
}
}
} else {//没有直接回目录
var person = {
tid: shortid,
eid: articleid,
Namepageid: function() {
return "/" + this.tid + "/" + this.eid + "/"
}
}
}
//下一章的url判断end
//滚动事件修改 href 属性
var url = person.Namepageid();
if (window.screen.availHeight >= document.body.clientHeight) {//没有滚动条直接修改href 属性
document.getElementById("next").setAttribute("href", ""+ url)
} else {
var tur = true;
function scrollBottomOrTop() {
var clients = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
var wholeHeight = document.documentElement.scrollHeight;
if (clients + scrollTop >= wholeHeight - 500) {//滚动条距离底部500px时执行修改href 属性
document.getElementById("next").setAttribute("href", ""+ url)
}
if (scrollTop >= 300) {//文章内容向上滚动300px时修改href 属性
document.getElementById("next").setAttribute("href", ""+ url)
}
tur = true
}
window.onscroll = function() {//500毫秒只执行一次
if (tur) {
setTimeout(scrollBottomOrTop, 500);
tur = false
} else {}
}
}
//滚动事件修改 href 属性end