How do I Scroll parent page to top when child page is click within iframe?


With this piece of code you make sure that your Parent page scrolls up again when a visitor clicks on a link in your Iframe! Very useful for high Iframes!

When you use an Iframe and your visitor clicks on a link in this Iframe, the Parent page usually remains as it is. This is especially fine with small frames, but what if you have a large Iframe that actually needs to blend into the rest of your website?

Then you want the entire page to scroll up again when you click on a link at the bottom of the Iframe. By adding the code below to your Iframe you ensure that when a visitor clicks on a link, the entire page scrolls up again.


The complete example could look like this:

<iframe onload="window.parent.parent.scrollTo(0,0)" style="width: 100%; height:2000px; border:3px solid black;  
     " src="jouw eigen" id="Iframe"></iframe>