• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is it possible to find the response status code of an iframe's content?

 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I need some help with finding out the status of an iframe.

In the web-app we are writing, we have an iframe that displays PDF documents (i.e src="document?contractNumber=234&docId=567"). The servlet mapped to by "document" uses the query parameters to get the document and stream it's contents to the response, with the ""application/pdf" Content-Type header. The rest of the page includes navigation controls which change the src of the iframe.

Now a few things can go wrong here - the document might not be found for whatever reason, the user's session might be expired, and other stuff like server errors. Is it possible to determine the status code of the iframe's content (200, 401, 404, 500, whatever) with javascript?

Thank you,
Yuriy
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I remember correctly, only IE supports it...
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, Eric!

The application is only requiredp to work with IE, though Firefox support would be nice. What is the method to check the status code with IE? I didn't see anything useful on the MSDN site.

If it's possible to get the content-type of the iframe content, that would be an acceptable workaround. If the javascript sees that the content-type is text/html, then it would know that something went wrong and could parse the frame's document for a custom error message.

Thank you,
Yuriy
[ July 21, 2005: Message edited by: Yuriy Zilbergleyt ]
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking for a link that talked about this and I am having no luck...Ah!

An all around solution basicaly is do something like my example that checks that the link exists with Ajax before going there.
http://radio.javaranch.com/pascarello/2005/06/24/1119626686861.html

Eric
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, I'll consider that, though it seems a shame to have to send two seperate requests for the same document, one of them just to check if the document exists or not. A similar idea is having the entire iframe element returned by Ajax - again two requests.

By the way, it seems IE doesn't fire an iframe's onload event if the iframe's src is a pdf file, but it does fire it if it's text/html. Guess that's one way to find out the content type in IE...

Thank you,
Yuriy
[ July 21, 2005: Message edited by: Yuriy Zilbergleyt ]
reply
    Bookmark Topic Watch Topic
  • New Topic