This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
Scroll: Top / Bottom not working for iFrames, here's a script #257
therksius
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A lot of the interfaces I work with use iframes, and they're quite long sometimes, and not being able to scroll to the bottom was infuriating. I made these two little custom scripts to help me out, figured someone else might benefit (only tested in Chrome).
The break down is:
Define a loop limit to prevent any infinite loops.
Set the working element (workElem) to the document active element.
- If workElem is ever non-truthy, exit the loop.
- If workElem has a contentDocument (implying iframe), set to the active element WITHIN the contentDocument, restart loop.
Store/memorize the current scroll position (scrollMem).
Attempt to set the scroll position to top/bottom.
Now compare the scroll position with memorized position:
- If position changed, the element can scroll, and we're done: break
- Else, set workElem to it's parent element, restart loop
Beta Was this translation helpful? Give feedback.
All reactions