Detecting Connection

Detecting Connection

i want to prevent the user from accessing a page in my mobile app unless the have a connection

i use this code but it doesnt seem to work

  1. $(document).ready(function()
  2. {
  3.  $('.MainLink').click(function()
  4.     {
  5.         if (!window.navigator.onLine)
  6.         {
  7.             return false;
  8.         }        
  9.      });
  10. });