473,545 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iFrames Page load

Hi,

I was wondering if anyone knew how to perform the following 2 tasks in
javascript:

1) distinguish between frames and iframes (during an onload event for
example)
2) figure out whether a container page has finished loading completely
with all its component frames or iframes (onload event is not useful
because we have more than one onload, and container page onload is not
always the last one for iframes).

Thanks,

-Adnan.

Jul 23 '05 #1
6 7086
In article <11************ *********@f14g2 000cwb.googlegr oups.com>, adnanx82
@gmail.com enlightened us with...
Hi,

I was wondering if anyone knew how to perform the following 2 tasks in
javascript:

1) distinguish between frames and iframes (during an onload event for
example)
Depends.
Checking from where, the window itself or a containing window?
Generally, you can't tell, but you might be able to fudge it by checking
getElementsByTa gName and putzing around.
2) figure out whether a container page has finished loading completely
with all its component frames or iframes (onload event is not useful
because we have more than one onload, and container page onload is not
always the last one for iframes).


I can't think of a way, other than having every child and the container set
variables when they load, then checking those variables.
A hack, basically. Not pretty.

--
--
~kaeli~
Practice safe eating - always use condiments.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
>>2) figure out whether a container page has finished loading completely
with all its component frames or iframes (onload event is not useful
because we have more than one onload, and container page onload is not
always the last one for iframes).

I can't think of a way, other than having every child and the container set
variables when they load, then checking those variables.
A hack, basically. Not pretty.


I don't know if this works for Mozilla or Opera, but using IE, you could
check the readyState of the (i)frames contained in your main window:

<html>
<head>
<script>
Globals={
checkReadyState :function() {
for (var f=0; f<document.fram es.length; f++) {
frame = document.frames (f);
while (frame.document .readyState!="c omplete") {
status+="."; // just wait ...
}
}
}
};
</script>
</head>
<body onload="Globals .checkReadyStat e();">
<iframe src="test.html" >
<iframe src="test.html" >
<iframe src="test.html" >
<iframe src="test.html" >
</body>
</html>
Jul 23 '05 #3
ad******@gmail. com wrote:
1) distinguish between frames and iframes (during an onload event for
example)
Unclear what the reference point is on this, but if the i/framed window
is wondering (and it's not a cross domain situation), what about:
window.frameEle ment.nodeName
2) figure out whether a container page has finished loading completely
with all its component frames or iframes (onload event is not useful
because we have more than one onload, and container page onload is not
always the last one for iframes).


One approach is to have a variable at the top level which each loaded
frame increments (in its onLoad routine). When all frames have
loaded, then the variable's value will equal the number of i/frames
(which each onLoad routine is, of course, checking for. In that
event, the top.everybodyLo aded routine can kick off). The post below
illustrates this for the two i/frame case (the variant at the bottom
is closer to what I'm talking about here).
http://groups-beta.google.com/group/...71708cb459e632

Good luck,
Csaba Gabor from Vienna.
Jul 23 '05 #4
Csaba Gabor wrote:
ad******@gmail. com wrote:
2) figure out whether a container page has finished loading completely
with all its component frames or iframes (onload event is not useful
because we have more than one onload, and container page onload is not
always the last one for iframes).


One approach is to have a variable at the top level which each loaded
frame increments (in its onLoad routine). When all frames have
loaded, then the variable's value will equal the number of i/frames
(which each onLoad routine is, of course, checking for. In that
event, the top.everybodyLo aded routine can kick off). The post below
illustrates this for the two i/frame case (the variant at the bottom
is closer to what I'm talking about here).
http://groups-beta.google.com/group/...71708cb459e632


Here's a concrete example that I put together on FF 1.0 / IE 6
that checks whether all the frames are loaded (but not for the
container page being loaded).

<html><head><ti tle>Multiload Test</title>
<script type='text/javascript'>
loadCount = 0;
function everybodyLoaded () {
alert("Number of frames loaded: " +
window.frames.l ength); }
</script>
</head><body>
<iframe src="javascript :'<body onload=&quot;
alert(&amp;#34; I\'m a/n &amp;#34;+
window.frameEle ment.tagName);
if (++parent.loadC ount==
parent.frames.l ength) parent.setTimeo ut(parent.
everybodyLoaded ,0)&quot;>Frame 1</body>'">
</iframe>
<iframe src="javascript :'<body onload=&quot;
if (++parent.loadC ount==
parent.frames.l ength) parent.setTimeo ut(parent.
everybodyLoaded ,0)&quot;>Frame 2</body>'">
</iframe>
</body>
<html>
Also, it is (I think) instructive to see what happens
if you replace the two lines starting with 'alert' in
the main body (in other words, lines 10 and 11) with
the following 3 lines:

window.setTimeo ut(&amp;#34;ale rt(
\\&amp;#34;I\' m a/n \\&amp;#34;+
window.frameEle ment.tagName)&a mp;#34;,0);

In this case, the alert does not hold up processing until
the onLoad of IFrame 1 has finished (by the alert being
responded to). Rather, that onLoad finishes along with
the others so that everybodyLoaded can run.

In IE6, the alert from everybodyLoaded (run from the onLoad
of IFrame 2) must be dismissed before the alert for IFrame 1
(pending from the setTimeout) will run.

However, in FF 1, both alerts will be shown, the IFrame 1
alert on top of the everybodyLoaded alert.

Csaba Gabor from Vienna
Jul 23 '05 #5
In article <42************ *********@read. news.be.uu.net> , je*@fernbach.co m
enlightened us with...

I don't know if this works for Mozilla or Opera, but using IE, you could
check the readyState
MSIE only http://msdn.microsoft.com/workshop/a...adystate_1.asp

Standards Information
There is no public standard that applies to this property.

--
--
~kaeli~
A lot of money is tainted - It taint yours and it taint mine.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #6
Thanks for your replies. Keeping a count of frames loaded works if the
frames are produced statically in the html. However, if there is
javascript code that generates frames dynamically, we don't know for
sure what the number of frames would be in the frames array when the
onLoad event is called for a particular frame (There might still be
more frames being added to the document).

I think setting variables in each frames window and container window
when that window's onLoad event fires might work. After setting the
variable, it could go through all the frames in the top window and if
all of them have the variable set to true, then we know that that
onLoad was the last onLoad and the page (with all the component
windows) has finished loading. However, again, I am not sure what the
implication is on pages which dynamically generate frames or iframes
using document.write( )...Will this work all the time? Is it possible
that all the frames in the frames array and the container page have
finished loading but there still other frames that are just about to be
added?

In case you're wondering, I'm writing a generic solution, so I don't
know about the structure of the pages and would like to have a generic
way of figuring out the completion of the load for a container page
along with all of its component frames/iframes.

Thanks very much for your help everyone.

-Adnan.

Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2074
by: Dan Popa | last post by:
Check out the following 2 links: http://www.batisdev.com/admin/test_1images.asp http://www.batisdev.com/admin/test_2images.asp First page contain 4 IFRAMES and 1 IMG tags. Second page contain 4 IFRAMES and 2 IMGs tags. The problem is that the second IFRAME from the second page generates fires a new session.
4
2006
by: Howard Jess | last post by:
In a javascript-heavy page, an iframe is created to hold information from a secondary server CGI process, and the resulting data (in the iframe) is used to rewrite some content in the main page. To do this transparently, the iframe is created with style="display: none". This scheme works great in IE and Mozilla; but Opera apparently doesn't...
1
1525
by: Tom Szabo | last post by:
I have been learning and practicing JS for a few weeks now. I have a good understanding of most things and came up with a few complex modules. Basically I am almost comlpleted my library code that is needed for some development soon. Unfortunately I am having a real confusion with IFrames. In order to achieve some of my goals I have arrived...
5
2217
by: Frances | last post by:
I need to replace iframes acc. to what option user chooses in a sel obj.. but figured have to load a blank iframe when pg loads so I can replace it.. (iframe gets put in a pre-existing div..) this is approach.. I'm having some problems and would appreciate some help.. thank you very much... var selItem; var ifrCurr; var div =...
8
3347
by: Ashish | last post by:
Incase the problem got bogged down reposting... Hi Gregory, I think I didnt make myself much clear. The problem is: 1. I have one ASP.NET application (no classic asp) and it has a main page (i.e. kinda SDI main window) that contains an IFrame. 2. I load different ASPX pages (that belong to the same ASP.NET project) in
7
3949
by: SHC | last post by:
I'm in need of some javascript to load two pages into two seperate iframes which are on two seperate and different pages. Rather complicated I know (and easier done in one frameset), but caused by some limitation issues of SharePoint. To help:
1
1225
by: bettyl | last post by:
I would like to know how to open two pages (from one link) into two different iframes on a different page. I already know how to open two pages in the iframes when they are on the parent page. <script language="javascript"> function loadTwo(iframe1URL,iframe2URL) { parent.cover.location.href=iframe1URL parent.text.location.href=iframe2URL...
2
12721
by: ericisjusteric | last post by:
I have a page with multiple iframes and need to have the user (ie6) be able to click a button to refresh any one of the iframes - but also to click another button at the top of the page to refresh all of them - from the server (this could be on page refresh also) as the purpose is to reset the iframe to the original content in case the user...
1
1921
by: bizt | last post by:
Hi, I have a webpage where Im creating AJAX type requests by loading dynamic pages containg JavaScript into hidden iFrames. The reason I am opting for this method over XmlHttpRequest object requests is because I wish for some of my requests to be over a secure https:// connection and other not so private requests to be made over http:// .....
0
7396
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7751
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5323
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1874
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.