Solved [Solved]Bookmarklet to scroll to bottom then scroll back to current position in website
-
I need this js function for CC, so that I can force some webpage with lazy load content to pre-loading hidden content while I'm browsing.
Basically, I need the js to remember current position, then scroll to bottom of the page, then scroll back to position when I execute the js.
Many thanks in advance.
-
Try this:
javascript:var currentScrollPosition=window.pageYOffset;window.scrollTo(0,document.body.scrollHeight);setTimeout(function(){window.scrollTo(0,currentScrollPosition)},1000);
It returns to the previous position after one second - you can adjust it by changing
1000
to another value (in milliseconds). The code is nested since you want to use it as a bookmarklet.See if it works against the "lazy load", as I'm curious myself. If not, we might have to add animation, to slow down the scroll.
-
Ppafflick moved this topic from Modifications on
-
@pafflick Thanks for the help, I add a bit of extra commands into CC to made it more compatible with various website's lazy load, here is the CC for those interested:
-
Ppafflick marked this topic as a question on
-
Ppafflick has marked this topic as solved on
-
Here is a slight improvement of @pafflick code, it will scroll downward smoothly till the end & trigger lazy load, then skip back to original position. Also, now it works even in Youtube or any webpage directly with
null
orundefined
scroll height.javascript:var currentScrollPosition=window.pageYOffset;window.scrollTo({ top: document.documentElement.scrollHeight, left: 0, behavior: 'smooth' });setTimeout(function(){window.scrollTo(0,currentScrollPosition)},1000);
-
Ppafflick unlocked this topic on