By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Catch a 404 when using an iFrame

P: n/a
I am using iFrames to integrate two systems at the HTML level.
If the included content in an iFrame is not available, how can I detect
this in the outer page in JavaScript?

Thanks, plex4r

Oct 6 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


plex4r wrote:
I am using iFrames to integrate two systems at the HTML level.
If the included content in an iFrame is not available, how can I detect
this in the outer page in JavaScript?


The frame will display the answer from the server and there are no
objects or properties on window or document to find out the HTTP
response status that resulted in the document sent.

If you know what kind of 404 error document that server sends you could
check the title perhaps e.g.
var frameDoc = window.frames.iframeName.document;
if (frameDoc.title == 'title the server sends for 404') {

Besides that you could make a HTTP HEAD request for the frame URL with
XMLHttpRequest in browsers that support that. There you can check the
HTTP response status code.

Both approaches work only if the container document and the frame
document are served from the same server.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 6 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.