New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to detect failed page load? #3525
Comments
Have NW.js load a local HTML file with a script to check. Then use one of these two methods.
You might have to set these timers higher based on the web servers response time. |
And if you want to see if the server itself is down you can do a quick check with |
@baconface Hey, thanks so much for the advice! I was struggling with this for a while and was finally able to make it work in a robust way with your advice about hooking into the iframe's |
@johnthedebs Awesome, glad it was of help. |
I'm using NW.js to load a remote site by setting
window.location.href
, and periodically reloading the app (to refresh the data after coming back from sleep, for example).Sometimes, the reload fails and if I inspect the value of
window.location.href
it's set todata:text/html,chromewebdata
rather than the URL I set it to, which I'm taking to mean it failed to load the page for some reason.I put a guard in place so that the reload wouldn't happen unless there's an active network connection (by resolving the DNS records of the URL being loaded before reloading), but in many cases the online check succeeds and the reload still fails.
Any ideas why this is happening? Is there a better way to guard against failed loads, or a way to check that a page has failed to load (or be notified about it)?
The text was updated successfully, but these errors were encountered: