Click here to Skip to main content
11,409,922 members (51,551 online)
Rate this: bad
good
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 at 17-Jul-12 3:08am
   
I read this but how to check the internet connection available or not?
Sandeep Mewara at 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
0 Sergey Alexandrovich Kryukov 270
1 OriginalGriff 255
2 Maciej Los 138
3 Andy Lanng 105
4 Sascha Lefévre 95
0 Sergey Alexandrovich Kryukov 8,771
1 OriginalGriff 6,905
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 17 Jul 2012
Copyright © CodeProject, 1999-2015
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