How to Figure Out the Cause of a Browser Window Ju

2019-08-20 02:03发布

simplified, have a html page in which an iframe is embedded in which a leaflet map is embedded:

<html>
...
  <iframe>
    ...
    <div class="leafletMap"></div>
    ...
  </iframe>
...
</html>

on top of the page is a form. on the bottom of the page is the iframe. the page has a scroll bar. if i load the page intially the page is scrolled to the top. if due to user interaction with the page the leaflet map within the iframe is reloaded the page jumps down to the bottom of browser window to the iframe.

aim is that the browser window does not jump to the bottom after a reload of the leaflet map. rather does not jump at all. if due to user interaction the leaflet map gets reloaded there should be no browser scrolling.

tried to overwrite the focus and/or scroll events of the window, iframe and leaflet objects without success. how is it possible to figure out what causes the page jump or how to prevent it in general?

1条回答
劳资没心,怎么记你
2楼-- · 2019-08-20 02:40

To disable scroll position, on parent page try below:

<script>history.scrollRestoration = "manual"</script>

Or, onunload/beforeunload event of the parent page

window.beforeunload = function(){ window.scrollTo(0,0); }
查看更多
登录 后发表回答