My Web page uses iframes to collect content from other pages. All pages are in the same domain.
From the main page, is there a way to confirm that all iframes have loaded, and that there is no 404 error?
My Web page uses iframes to collect content from other pages. All pages are in the same domain.
From the main page, is there a way to confirm that all iframes have loaded, and that there is no 404 error?
The status only lives in the response header.
The 404 Page is handling an HTTP Status Code, which is only included in the server's response sent to the browser, but not in the actual
window
anddocument
objects of the DOM that javascript may access. This means that while you certainly can collect the status-code and take appropriate actions, you may only do so when your javascript is receiving the response, such as with a jQuery.ajax() request or an XmlHttRequest to load your "iframe".Hope the 404 page follows 404 standards.
If the above isn't an option, the only other possibility may be to check the title, and/or H tags, for " 404 ". While this is most certainly less than ideal (I'd love to see, "404, Movie not Found, the Movie."), it is your only other option.
Suppose this is your html
There are two scenario
Your iframe's src is in the same domain from where your page is originated.
You can use jQuery ajax request to check if the the resource is available
Your iframe's src is not pointing to the same domain from where your page was originated.
Now browsers will not let you make a cross site request from javascript code due to cross origin policy. The way around is to make a jsonp request.