This article is mainly to the JavaScript back to the top effect of the implementation code is introduced, need friends can come to the reference, I hope to help you
The code is as follows://speed scrolling speed time interval function gototop (speed,time) {speed = Speed | | 0.1; Time = Time | | 16; The horizontal distance of the scroll bar to the top of the page var x = document.body.scrollLeft; The vertical distance of the scroll bar to the top of the page var y = document.body.scrollTop; Rolling distance = current distance/speed, because the smaller the distance, the speed is greater than 1 of the number, so the rolling distance will be more and more small speed++; Window.scrollto (Math.floor (x/speed), Math.floor (Y/speed)); If the distance is not zero, continue to invoke the iteration this function if (x > 0 | | | y > 0) {window.settimeout ("Gototop + Speed +", "+ Time +") ", t IME); } }