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
LVL 2
alexmayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
Telling you what's happening within the iframe's will take too much of my psychic powers at the moment ;-)

But a workaround could be having <iframe name="frame1" id="frame1" src="" /> and then setting the src attribute after the onresize event has taken place:

<script type="text/javascript">
   var frames_loaded = false;
   function loadframes()
   {
     if(frames_loaded) return; //only load once.
     document.frames.frame1.src="http://somewebsite";
     frames_loaded = true;
   }
</script>
<body onresize="resizefunction();loadframes();">

Regards

-r-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
baboo_Commented:
So's we all know, I expect that what Roonaan suggests would work...

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_
0
alexmayAuthor Commented:
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
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

RoonaanCommented:
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">
someFunctionWhichIsAlsoCalledOnResize();
</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-
0
alexmayAuthor Commented:
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
0
RoonaanCommented:
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-
0
alexmayAuthor Commented:
Excellent.
It works fine.
Thanks
Alex
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.