Created
February 18, 2021 10:57
-
-
Save VorticonCmdr/43da6a8ff0274763f7d5fadcea2d438c to your computer and use it in GitHub Desktop.
scroll the page via #anchor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scrollTo() { | |
if (navigator.userAgent.indexOf("Googlebot") == -1) { | |
return; | |
} | |
if (!window.scrollBy) { | |
return; | |
} | |
var pagePattern = /page=(?<page>\d+)/; | |
var matched = document.location.hash.match(pagePattern); | |
if (!matched || !matched.groups || (!matched.groups.page) ) { | |
return; | |
} | |
var page = parseInt(matched.groups.page); | |
window.scrollBy(0, window.innerHeight*page); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment