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?
404 error or 'page not found' error is a Hypertext Transfer Protocol standard response code that indicates the server was unable to find what was requested. This message may also appear when the server is not willing to disclose the requested information or when the content has been deleted.
The simplest and easiest way to fix your 404 error code is to redirect the page to another one. You can perform this task using a 301 redirect. What's 301, you may ask? It's a redirect response code that signals a browser that the content has been transferred to another URL.
404 is a status code that tells a web user that a requested page is not available. 404 and other response status codes are part of the web's Hypertext Transfer Protocol response codes. The 404 code means that a server could not find a client-requested webpage.
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
and document
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".
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.
$('#iframe').load(function (e) { var iframe = $("#iframe")[0]; if ( iframe.innerHTML() ) { // get and check the Title (and H tags if you want) var ifTitle = iframe.contentDocument.title; if ( ifTitle.indexOf("404")>=0 ) { // we have a winner! probably a 404 page! } } else { // didn't load } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With