I have a script that inject an Iframe to my page, In rare occasions the service is down and the Iframe content is a 404 page content.
Can I detect somehow that the response of a cross domain page ( in-iframe ) is 404?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The simple answer is “no,” not without CORS or help on the server side. The whole point of the same-origin policy is that you can’t get information about content served from somewhere else.
Try using a server-side script to make a HEAD request to the site in question and make sure it’s up.
Another possible workaround: Find an image on their site, and try to load that first. When the image loads, load the iframe. If it fails to load after some period of time, you can assume the server’s down, and show a custom “oops” message. May or may not work depending on what’s actually going on with that server.