Last active
October 13, 2022 00:35
-
-
Save magasine/935e355a7e72e44834396ae0aef47b0e to your computer and use it in GitHub Desktop.
! Save-Load Scroll Position Toggle (bookmarklet)
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
javascript: (function () { | |
if (!localStorage.getItem("position")) { | |
localStorage.setItem("position", document.documentElement.scrollTop); | |
target = prompt('Saved positon at: ' + localStorage.getItem("position") + '\nDefine a tag: ', '#yourTagName'); | |
} else { | |
scrollTo(0, localStorage.getItem("position")); | |
alert('Go to load "' + target + '" at scroll position: ' + localStorage.getItem("position")); | |
localStorage.removeItem("position"); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment