View Full Version : iframes loading order

06-21-2006, 10:31 AM
hey all..

I have multiple iframes in a page, and i need to control the way the pages are loaded in them.. giving priority..

basically, if i have a left iframe and and right iframe, and i have the main content loading in the right iframe, then i want that iframe to load first, followed by the left..

can anyone help me with this? i found a script that does it for framesets here (http://javascript.internet.com/navigation/frames-load-order.html)

but how to do it for iframes?

06-21-2006, 12:33 PM

You can load the write a function on the body load() , which specifies the order of the IFrame to the loaded.


<body onload="LoadIframe()">


function LoadIframe()
document.getElementById("leftFrame").src = "FrameLoad2.htm";

Let me know if u have any doubts.




06-23-2006, 06:25 AM
hey vallim,
thanx for that, but somehow it doesnt seem to work..

this is a web application interface done long back in a frameset.. it had 4 frames, loading 4 different php files. now am trying to migrate the whole thing into iframes as a temporary solution, due to some urgent requirement.

i have a top iframe, a navigation iframe below that, a left iframe and a main iframe.. and the main iframe has to load the respective php file 1st, followed by other frames.

tried what u said, but it didnt work..

06-23-2006, 09:38 AM
The thing about iframes is that they are like having seperate windows.
They load as they can and load independantly of each other.

If one frame's server is busy, and the other isn't... or vice versa... etc.

So... not sure how controlling them will work.

The above script probably works just fine, but only controls when they START loading... so... frame1 starts, then frame2, then they both go at their own pace, independantly.

Maybe I'm wrong here, but I don't think there's any waiting line for iframe loading... not in the browsers I use anyway.

06-23-2006, 12:05 PM
yeah, i think that's what's happening now. the page that has to be loaded is the heaviest, so it still takes times and meanwhile the rest is already downloaded..

as for the server, all the pages are from the same server..so no issues with that..

there is a script that controls the loading in a frameset..

it loads 1 frame 1st and only after that it lets the other one load. that's the stuff am looking for, but for iframes

06-23-2006, 09:13 PM
Ok, well if they're all on the same server, then that variable is out... the only difference is page complexity and what graphics+ are on the page. So... yeah, the "heavier" one will take longer. Just gotta deal with it.

Now... maybe you could stop the other ones from loading then load them after the other one is complete, but is it really that important?

Perhaps an onLoad="" in the iframe, but I don't know if that applies to iframes. There is probably some javascript for it, though.
Perhaps using onLoad="" in the body tag of the included page, sending a value to its parent page, and thereby starting the other ones loading. Pretty complex, though.