Click here to Skip to main content
12,240,300 members (62,678 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Javascript HTML
hello friends,
i work on html5 i want to know that how to use local storage in html5 and check internet connection.
My problem is that i want to store the data in local storage when internet connectivity not available and when internet connection available the data restore on sever when internet connection available. i want to use html5 for that.


thanks in advance.
Posted 16-Jul-12 21:29pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

local storage in html5
Read all about them here:
HTML5 Web Storage[^]
HTML5 Local Storage – Complete Guide[^]
HTML5 localStorage – Part One[^]
HTML5 localStorage – Part Two[^]

It will help you understand on how it can be used.

UPDATE:
how to check the internet connection available or not?
You can determine that the connection is lost by making a request to any URL using XMLHttpRequest. A failed XHR request will confirm no connection.

Though the best one is to use navigator:
Sample:
if(navigator.onLine)
  {
    alert('You are Online');
  }
  else
  {
    alert('You are Offline')
  }
Refer: Check Network Status using HTML5 and Javascript [^]
  Permalink  
v2
Comments
niravbhavsar 17-Jul-12 3:08am
   
I read this but how to check the internet connection available or not?
Sandeep Mewara 17-Jul-12 3:27am
   
Answer updated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 17 Jul 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100