@*Remember the position of the scroll bar when clicking the button to refresh the page*@ Copy code The code is as follows: <br>window.onbeforeunload = function () { <br>var scrollPos; <br>if (typeof window.pageYOffset != 'undefined') { <br>scrollPos = window.pageYOffset; <br>} <br>else if (typeof document.compatMode != 'undefined' && <br>document.compatMode != 'BackCompat') { <br>scrollPos = document.documentElement. scrollTop; <br>} <br>else if (typeof document.body != 'undefined') { <br>scrollPos = document.body.scrollTop; <br>} <br>document.cookie = "scrollTop=" scrollPos ; //Store the scroll bar position in cookies <br>} <br><br>window.onload = function () { <br>if (document.cookie.match(/scrollTop=([^;] )(; |$)/) != null) { <br>var arr = document.cookie.match(/scrollTop=([^;] )(;|$)/); //If cookies are not empty, read them Scroll bar position <br>document.documentElement.scrollTop = parseInt(arr[1]); <br>document.body.scrollTop = parseInt(arr[1]); <br>} <br>} <br>< /script> <br> </div>