Which function in html can I use to make it ... That when I open website and become offline so it show alert that "You are offline please turn on internet connection to run website."
Asked
Active
Viewed 777 times
-1
-
6Possible duplicate of [Detect the Internet connection is offline?](https://stackoverflow.com/questions/189430/detect-the-internet-connection-is-offline) – Anthony L Feb 20 '18 at 04:57
2 Answers
3
You can use window
offline
event
window.addEventListener('offline', function(event){
alert("You are offline please turn on internet connection to run website");
});

Vineesh
- 3,762
- 20
- 37
2
Try this.
var online = navigator.onLine;
if (online == false)
{
alert("Sorry, we currently do not have Internet access.");
location.reload();
}

Arsalan Akhtar
- 395
- 2
- 15