alexmay
asked on
OnResize waiting for load completion a problem with iFrames
I have a page full of iFrames containing external data.
For reasons that are not entirely clear to me, the content of these iFrames often never stops loading.
This is a problem to me because on my page, I want to fire a script onResize of the window.
I have attached the script to the onResize event in the body tag, but it does not seem to fire.
As soon as I ditch the content of the iFrames, the onResize works.
Can anyone explain what is going on here (does onResize wait for load completion) ?
And can anyone suggest a workaround (can I fool the browser into thinking everything is loaded or use a different event) ?
Thanks for your help.
best regards,
Alex May
For reasons that are not entirely clear to me, the content of these iFrames often never stops loading.
This is a problem to me because on my page, I want to fire a script onResize of the window.
I have attached the script to the onResize event in the body tag, but it does not seem to fire.
As soon as I ditch the content of the iFrames, the onResize works.
Can anyone explain what is going on here (does onResize wait for load completion) ?
And can anyone suggest a workaround (can I fool the browser into thinking everything is loaded or use a different event) ?
Thanks for your help.
best regards,
Alex May
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your answer sounds good thanks.
After some effort, I even managed to pack this idea into my page.
It doesn't help to wait for the resize event because I want the page content right away.
However it seems possible to me that the onresize might work, if the page loads correctly once without the content and the content is only put into the frames once the page is loaded ie with onload.
Trouble that I have right now is that the problem has gone away.
I mean to say that it is currently not reproducible (with or without the workaround).
So I don't know if the workaround works!
I think I need a problem in the foreign pages in the iframes to provoke the problem.
You don't know how I can simulate that so that I can see if the solution works do you?
Would some kind of a php never ending loop work?
regards,
Alex
After some effort, I even managed to pack this idea into my page.
It doesn't help to wait for the resize event because I want the page content right away.
However it seems possible to me that the onresize might work, if the page loads correctly once without the content and the content is only put into the frames once the page is loaded ie with onload.
Trouble that I have right now is that the problem has gone away.
I mean to say that it is currently not reproducible (with or without the workaround).
So I don't know if the workaround works!
I think I need a problem in the foreign pages in the iframes to provoke the problem.
You don't know how I can simulate that so that I can see if the solution works do you?
Would some kind of a php never ending loop work?
regards,
Alex
You could always try to add the function to the end of your page, just in front of the </body> tag:
<script type="text/javascript">
someFunctionWhichIsAlsoCal ledOnResiz e();
</script>
</body>
this way, the resizing code is called one extra time, even before the onload event is triggered or the page is fully loaded.
Regards
-r-
<script type="text/javascript">
someFunctionWhichIsAlsoCal
</script>
</body>
this way, the resizing code is called one extra time, even before the onload event is triggered or the page is fully loaded.
Regards
-r-
ASKER
No, no, no, we are now off on the wrong track.
The problem is not that I can't get a function to call at all, but that I need the onresize to work so that I can trigger a function when the page/window is resized.
I think you might have the solution Roonaan (loading the iframes without content and then adding the content with an onload function). If the page loads once, I don't see why onresize wouldn't work after that (although I can't find any documentation that says that it waits for the page load to complete before working in the first place!).
But as I said above, I am not sure how to test the solution at the moment.
I will increase the total points to take account of this added bit of the puzzle!
Obviously if Roonaan's solution works and someone else tells me how to test it,
I will split the points.
best regards,
Alex
The problem is not that I can't get a function to call at all, but that I need the onresize to work so that I can trigger a function when the page/window is resized.
I think you might have the solution Roonaan (loading the iframes without content and then adding the content with an onload function). If the page loads once, I don't see why onresize wouldn't work after that (although I can't find any documentation that says that it waits for the page load to complete before working in the first place!).
But as I said above, I am not sure how to test the solution at the moment.
I will increase the total points to take account of this added bit of the puzzle!
Obviously if Roonaan's solution works and someone else tells me how to test it,
I will split the points.
best regards,
Alex
Testing code. Runs about 10 minutes. Should be enough I suppose
<?php
for($i = 0; $i < 600; $i++)
{
echo $i;
flush();
usleep(1000);// wait one second
}
?>
Regards
-r-
<?php
for($i = 0; $i < 600; $i++)
{
echo $i;
flush();
usleep(1000);// wait one second
}
?>
Regards
-r-
ASKER
Excellent.
It works fine.
Thanks
Alex
It works fine.
Thanks
Alex
That said, the apparent non-determinism and general buggery of JavaScript (sometimes) leads me to believe that it might help to have your site exorcised...
Seriously, though, if Roonaan's suggestion doesn't work, could you post some of your code?
baboo_