location.hash in an iframe scrolls the parent window
- by Ben Clayton
Hi all. I have a page with an iframe. Inside the iframe is code (that I can't change) that sets location.hash to the id of an element in the iframe window.
This has the unwanted effect of scrolling my outermost browser window so that the top of the window touches the top of the iframe. This is quite annoying as I have a toolbar above the iframe that is vital to my app.
Is there any way of preventing the setting of location.hash affecting the scroll position of the main window?
Will preventDefault help me out here?
Thanks!