If there is ever a moment when you need your internet connection to
work, there is a very good chance it is at that very moment
your internet connection will fail. This is one of those universally
accepted truths...I think. Anyway, building an app or a site whose
functionality relies on an internet connection being present is tricky. You can't always guarantee that an internet connection
will be available when your app requires it, and this is
especially true on mobile devices when your internet connectivity might
be flaky.
Can you set a breakpoint and see where it is failing? This code is JS, but it shouldnāt have any problems working on the browser side of your ASP.net app
Hi I am running this script on client side and always getting the return value as false. I am actually using JS code in SmartGWT using JSNI but it always return false. Can you also help me with the timer so that this is checked frequently as I really need it and I would really appreciate your help
Ok can you tell me how can this function call some other domain to verify for Internet Connection. I mean cross-domain connectivity in Javascript. Thanks in advance!
Security restrictions will prevent you from calling JS code on another server directly. There are some tricks you can use. Before I consider mentioning them, Iām assuming you canāt modify (or add) code on the other server.
The internet-connection test works but I need to have it checked in a form when the Send-button is clicked before sending the email and I have no clue.
I tried a couple of things but all without result.
I feel like this is a non-issue. If PHP is executing any code at all, that means itās just received a request (99.99% likely over the internet) from a browser. If erwin007 is talking about some crazy setup where thereās some super weird LAN restrictions and the client and server are basically co-located, then that should be clarified.
OTOH, maybe erwin007 just wants to know that $('#myForm').on('submit', async e => await checkInternet() ? true : e.preventDefault()) is a thing.
I donāt know java, so even a simple thing becomes impossible for me, what i would like to do is to use this code on a simple link, if internet exists open the link if not show a message, is there some example of this somewhere, i was not able to find. Second i would like to do the same for Iframes if internet exists show the contents of the iframe, if not show message.
Hey all, so would this code work if I also wanted to check to see if an IP address is connected to a network? I want to see if an IP address is online or offline?
Unfortunately, no. There is no way in JS to ping a particular IP address and read the result. Is that IP address a web server? If so, you could check for the existence of a file on it as an indirect way of checking whether that IP address is connected to the network. This tutorial walks through how you can do that: https://www.kirupa.com/html5/checking_if_a_file_exists.htm
Hi,
Just wanted to check, will it execute at a certain period of time?
Suppose when i start my application the internet connection is there, but then in between the internet connection is lost in that case will the readyStateChange event auto fires?