How to check internet connection using javascript