Previously, it was quite helpful to find the JS effect at the top of a website. The only difference was that Google couldn't support it. After modification, it can now be tested. Now I have posted the code for your reference. I hope this will help you.
<Script type = "text/javascript">
Var Sys = {};
Var ua = navigator. userAgent. toLowerCase ();
Var s;
(S = ua. match (/msie ([\ d.] + )/))? Sys. ie = s [1]:
(S = ua. match (/firefox \/([\ d.] + )/))? Sys. firefox = s [1]:
(S = ua. match (/chrome \/([\ d.] + )/))? Sys. chrome = s [1]:
(S = ua. match (/opera. ([\ d.] + )/))? Sys. opera = s [1]:
(S = ua. match (/version \/([\ d.] +). * safari /))? Sys. safari = s [1]: 0;
Function goTopEx (){
Var obj = document. getElementById ("goTopBtn ");
Var scrollTop = window. pageYOffset | document.doc umentElement. scrollTop | document. body. scrollTop | 0
Function getScrollTop (){
Var xsun = document.doc umentElement. scrollTop;
If (Sys. chrome ){
Xsun = document. body. scrollTop;
}
Return xsun;
}
Function setScrollTop (value ){
If (Sys. chrome ){
Document. body. scrollTop = value;
}
Else {
Document.doc umentElement. scrollTop = value;
}
}
Window. onscroll = function () {getScrollTop ()> 0? Obj. style. display = "": obj. style. display = "none ";}
Obj. onclick = function (){
Var goTop = setInterval (scrollMove, 10 );
Function scrollMove (){
SetScrollTop (getScrollTop ()/1.1 );
If (getScrollTop () <1) clearInterval (goTop );
}
}
}
</Script>
The header-defined var Sys ={}; is used to determine the browser, which is very useful.
Page call method:
<DIV style = "DISPLAY: none" id = goTopBtn> </DIV>
<SCRIPT type = text/javascript> goTopEx (); </SCRIPT>