Home > front end >  UC, quark browser transcoding, deal with UC, quark browser transcoding, UC, quark browser transcodin
UC, quark browser transcoding, deal with UC, quark browser transcoding, UC, quark browser transcodin

Time:09-15

Saw the station is such a novel UC, quark transcoding, his next chapter links are empty "& lt; A href="" & gt; The next chapter & lt;/a>" , and then use js scroll event to modify the href attribute,

Js code is as follows:

In the HTML page statement several variables,

 

Articleid=var shortid="xx", "xx", next_chapterid="xx";//xx to fill in your own ID

//the url of the next chapter judgment
If (next_chapterid!=="") {//judge whether there is the next chapter
Var person={
Dar: shortid,
Eid: articleid,
Nextid: next_chapterid,
Namepageid: function () {
Return this. "/" + dar + "/" + this. Eid + "/" + enclosing nextid + "HTML"
}
}
} else {//not directly back to the directory
Var person={
Dar: shortid,
Eid: articleid,
Namepageid: function () {
Return "/" + this. Dar + "/" + this. Eid + "/"
}
}
}
//the url of the next chapter judging end

//scroll event modify href attribute
Var url=person. Namepageid ();
If (window. Screen. AvailHeight & gt;=document. Body. ClientHeight) {//not scroll bar directly modify the href attribute
Document. The getElementById (" next "). The setAttribute (" href ", "" + url)
} else {
Var tur=true;
The function scrollBottomOrTop () {
Var clients=window. The innerHeight | | document. The documentElement. ClientHeight | | document. Body. ClientHeight;
Var scrollTop=document. DocumentElement. ScrollTop | | window. PageYOffset | | document. The body. The scrollTop;
Var wholeHeight=document. DocumentElement. ScrollHeight;
If (clients + scrollTop & gt;=wholeHeight - 500) {//the scroll bar at the bottom of the distance 500 px executed when modify the href attribute
Document. The getElementById (" next "). The setAttribute (" href ", "" + url)
}
If (scrollTop & gt;=300) {//content scroll up to 300 px modify href attribute
Document. The getElementById (" next "). The setAttribute (" href ", "" + url)
}
Tur=true
}
Window. Onscroll=function () {//500 milliseconds to execute only once
If (tur) {
SetTimeout (scrollBottomOrTop, 500);
Tur=false
} else {}
}
}
//scroll event modify href attribute end

CodePudding user response:

Thanks for sharing ~!

CodePudding user response: