I have an HTML document which, towards its bottom, contains an iframe.
In this case, the iframe embeds a Google Spreadsheet, with the code:
I believe that this iframe contains some javascript that causes its parent window to scroll to the top on certain events, such as when its loading is complete or its content is navigated in certain ways. (This behaviour persists if the iframe is embedded within a second iframe.)
If I can't directly modify the source code of the iframe, can I prevent a parent window from being manipulated by javascript in iframe-embedded content?
What I've tried
I'm grateful to the commenters for suggestions, none of which have sadly solved the problem:
- Adding
sandbox="allow-scripts allow-forms allow-pointer-lock allow-same-origin"to theelement (to removeallow-top-navigation; @CBroe). - Overriding
window.scrollTo(@Ryano) - Putting the iframe in a separate iframe (@Ryano)