Detecting if the user is online with JavaScript