JQuery, which event is better than this?

I have a page in html (parent page) which is inside an iframe. When you navigate inside the iframe (reload the iframe page or click the link), the parent page remains at the previous position. Therefore, I used scrollTop to return to the top of the page.

Everything works fine, but jquery only does this when the iframe is fully loaded (attached image), so this is bad ...

How to scroll a (PARENT PAGE) page until the iframe page is fully loaded?

Parent page internal code:

<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function() { $('iframe').load(function(){ $(window).scrollTop(0); }); });</script> <iframe frameborder="0" height="1000" id="iframe" src="http://mysite.com" width="800"></iframe> 

Thanx !!!

+1
source share
3 answers

I think you could just do this:

 <script type="text/javascript"> jQuery(document).ready(function() { $(window).scrollTop(0); }); </script> 
0
source

may be?

 $('iframe').ready(function(){ $(window).scrollTop(0); }); 
0
source

This should work if I read it correctly:

 $('.mylink').click(function(){ $('html, body').scrollTop(0); $('#iframe1').attr('src', 'http://some-other-url'); window.frames["iframe1"].location.reload(); }); 
0
source

All Articles