Detect If Internet Connection Exists with JavaScript

There are times when the user might be browsing and loose the internet connectivity all of a sudden or user might be doing an offline browsing which comes basically from HTML 5 and the mobile...