看到一个小说站是这样防百度、UC、夸克转码的,他的下一章 href 是空的下一章”。然后利用js的滚动事件修改 href 属性。正常浏览时必然会滚动页面,滚
动页面就触发了修改 hrdf 的事件,对正常浏览是没有任何影响的。(这个站是章节带分页的,百度浏览器转码页显示的全是“第五章(1/3)页、第六章(1/2)页。(2/3)页、(3/3)页无法显示”,百
度好像是从目录页直接转码的。)
原理:UC或夸克浏览器转码情况下打开页面时会自动进入转码页面,但下滑加载下一章的时候会出现无法加载下一章的提示,这时就会出现返回源页面的提示。
注:能加载下一章就不会有上面的提示,一只在他的转码页面里。
html代码
主题收费区域
各种浏览器转码解决办法
…………
下一章
//在html页面声明一下几个变量。
var shortid = "{?$xxx?}", articleid = "{?$xxx?}", next_chapterid = "{?$xxx?}" , pageNow = "{?$xxx?}" , pageAll = "{?$xxx?}";//xxx填写你自己的ID
>
js代码如下:
主题收费区域
//下一章的url判断
if (pageNow = 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 {}
}
}