Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

OnResize waiting for load completion a problem with iFrames

Posted on 2004-11-18
7
Medium Priority
?
299 Views
Last Modified: 2012-06-22
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
0
Comment
Question by:alexmay
  • 3
  • 3
7 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 2000 total points
ID: 12613822
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
 
LVL 3

Expert Comment

by:baboo_
ID: 12614194
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
 
LVL 2

Author Comment

by:alexmay
ID: 12614400
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 49

Expert Comment

by:Roonaan
ID: 12614466
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
 
LVL 2

Author Comment

by:alexmay
ID: 12614604
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
 
LVL 49

Expert Comment

by:Roonaan
ID: 12614745
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
 
LVL 2

Author Comment

by:alexmay
ID: 12615047
Excellent.
It works fine.
Thanks
Alex
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question