How to scroll parent page with iFrame reload

I have a page with a long iframe on it that loads a schedule display with pages of different lengths. However, when a new page is displayed in an iframe, the main page often shows the bottom of the page (many spaces). How can I scroll the main page at the top anytime a new page loads in an iframe?

This is the page

I tried this jQuery (on the parent page):

<script type="text/javascript"> jQuery(document).ready(function() { $('#body iframe').load(function(){ $(window).scrollTop(0); }); } </script> 

Thanks!

+4
source share
1 answer

You don't have enough closing ) to call .ready() , and you shouldn't have # before body .

Try the following:

 jQuery(document).ready(function() { $('body iframe').load(function(){ $(window).scrollTop(0); }); }); 

With these fixes, the window returns to the top when loading new content.

+7
source

All Articles