Reputation: 3859
IM writing some html which provides a preview function for a list of URLs. I want to use an iframe for this functionality,
The issue arises when some of the URLs are broken (returning a 500 error) or when a page contains some authenication process which the requesting user cannot satisfy. In these situations the iframe is trying to display the URL but the content returned in the frame is useless (500 error or authenication error ) to the user.
DOes iframe have any built in error handling for these senarios or is there some other way i can display a generic error page if something happens when loading the iframe?
Thanks
Upvotes: 1
Views: 2706
Reputation: 88697
AFAIK, there is no way to directly access the header of a response to a request initiated by an iframe (or indeed, any request) in client side script.
This is slightly convoluted, but I think it would work:
src
to the actual URL (you might be able to do something as simple as window.location.href =
but I'm not sure without testing).If you know PHP/have it available on your server, I can try and provide a code example.
Upvotes: 1