468,780 Members | 2,357 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,780 developers. It's quick & easy.

Detecting when a page has loaded in a sub frame via javascript?

Hi
Given a web page using frames, is there anyway the left frame can request a
page in the right frame and, most importantly, detect when it has fully
loaded?
Ideally this requires no changes to the original web page being loaded on
the right.
Something like document.frame2.fullyLoaded? You get the idea

Thanks
F
Jul 20 '05 #1
3 8131


fo******@yahoo.co.uk wrote:
Given a web page using frames, is there anyway the left frame can request a
page in the right frame and, most importantly, detect when it has fully
loaded?
Ideally this requires no changes to the original web page being loaded on
the right.


With IE5.5/6 on Win you could from the first frame call

parent.document.getElementsByTagName('frame')[1].attachEvent('onload',
function (evt) {
// just an example, handle the load event here
alert(evt ? evt.type : event.type);

}
);

and then set
parent.frames[1].location = 'whatever.html';
With Mozilla and Netscape 7 you can from the first frame call

parent.document.getElementsByTagName('frame')[1].addEventListener('load',
function (evt) {
alert(evt ? evt.type : event.type);
},
true
);

and then set
parent.frames[1].location.href = 'whatever.html'

With other browsers you will have to use <body onload> in the document
loaded in the frame

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
thats fantastic thank you!

one other thing though...

will this tell me when the page has fully finished loading? i.e. all
images loaded and all possibly all scripts on the page run?

anyway way of finding out if the page didn't load correctly? guessing
something
like <pseduo code> if(body.text == "couldn't find page requested")
</pseudo code> or better

Thanks for you help

F
Jul 20 '05 #3
On 27 Feb 2004 01:51:15 -0800, <fo******@yahoo.co.uk> wrote:

[snip - use of unload event]
will this tell me when the page has fully finished loading? i.e. all
images loaded and all possibly all scripts on the page run?
Maybe, maybe not. There's no real way of telling. Different browsers use
different criteria when determining whether a page has loaded. Some
include images - some may even include Flash objects and Java applets.
anyway way of finding out if the page didn't load correctly?


[snip]

The only assured way of determining if a page loaded or not is by checking
the HTTP Response Status header, as servers may return any document when a
resource can't be loaded (so checking the contents of the page is a
possibility). Unfortunately, JavaScript cannot read the Response codes (it
can't read HTTP headers in general).

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by RootShell | last post: by
4 posts views Thread by Catherine Lynn Smith | last post: by
2 posts views Thread by Halldór Ísak Gylfason | last post: by
1 post views Thread by Unregistered | last post: by
3 posts views Thread by bfmcfarlane | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.