-2

Say I have set up a page with 8 frames, each frame tries to load different URLs in my LAN. If one or more of these URLs (belonging to local web servers) fail to load, I get the ugly error screen. Is there any way I can force that frame(s) to load an alternate URL if it times out or we can't catch that?

ThankS!

1 Answers1

0

Your post lacks sufficient information to answer it fully. This Answer is just resource help & knownledge. Hope you find it helpful.

If you are http://localhost/ as your main page, and the iframes are on the same host domain http://localhost/ you should be able to read the iframes & their content with javascript.

If you are lets say http://mywebsite.com/ and you are trying to access http://localhost/ you'll run into a wall, because web browsers are built to prevent you from interacting with the sub-domain or iframe bacause of Same-Origin-Policy.

If you control http://localhost/ you can add the headers or permissions to allow Same-Origin-Policy to overrode. CORS for short. Not sure if it allows iframe access, i dont use iframe much anymore, i just use AJAX. Which for you i'd recommend looking into because it can handle ERROR PAGES exactly the way you want.

If you control both the HOST http://mywebsite.com/ & http://localhost/ you can put javascript on both pages & allow them to communicate with each other. But if you are getting error pages, it is unlikely you can control error page responses.

Matthew
  • 49
  • 5
  • What does it all has to do with redirecting to an alternative URL when the main one times out? – PM 77-1 Apr 17 '18 at 15:50
  • Yeah Im calling a web document on a WAN that composes the frames and each frame contains calls lo LAN IPs. If any fails to load, I'd like to redirect the frame to a different URL. Is that possible? – Àlex Tutusaus Apr 17 '18 at 16:28
  • iframes have rules, JavaScript has rules, you cant make what you want happen without understanding the rules. The resources i listed will help you understand the rules. Also posting more information about your problem would help. Another solution, if you control the iframe host, is setting htaccces custom error pages or redirects. You might need professional help to come and look personally at what your trying to do. – Matthew Apr 18 '18 at 05:28
  • Yes I do have access to both the host and local pages, of course. Im not sure what piece of information is missing... I mainly have an index.html that is composing a set of frames in the screen, and each frame calls to a LAN IP (192.168.1.xxx). If one of these IPs fail to load (due to server being down), I'd like to redirect it to whatever URL I want, if possible. – Àlex Tutusaus Apr 18 '18 at 07:40
  • BTW Im not using – Àlex Tutusaus Apr 18 '18 at 13:07
  • What error code is showing up in the iframe the is failing to load? https://www.w3.org/Protocols/HTTP/HTRESP.html – Matthew Apr 18 '18 at 13:30
  • What error code is showing up in the iframe the is failing to load? https://en.wikipedia.org/wiki/List_of_HTTP_status_codes Also naming or giving your Frames The Easier solution to someone who understands javascript better is just use AJAX to make your request. It literally gives you the RESPONSE code of 200, 400, 500, etc. – Matthew Apr 18 '18 at 13:40
  • The question is: if there's no webserver replying to the other end, is an HTTP response still be sent or is it simply the browser considering it a timeout? I get the same response that you'd get if you try to reach your local webserver but forgot to plug it in on the wall.... Browser tries it for a while, then desists. – Àlex Tutusaus Apr 20 '18 at 14:06
  • Do you got some better way to chat this out? i use discord and skype and email. – Matthew Apr 20 '18 at 15:01