A lot of people over the net ask the same question about detecting an internet connection state using javascript. This one is from ASP.NET forums. How to find out if the Internet connection is connected or disconnected in ASP.NET?

But ASP.NET runs on the server, so if the user’s Internet connection is disconnected, then the browser will not be able to connect to the webserver to run ASP.NET code, that’s why I thought this code should be client-side, so I dug a little in java-script and here is an example of what I found out:

<script language="javascript">function CheckOnline()
      alert("You're online");
      alert("You're offline");
<body onload ="CheckOnline()">

I test it on Internet Explorer 7 and Mozilla and it worked well.