Localstorage not working on android.
I have a weird issue getting localstorage working on JQM.
My code works perfectly fine viewed on a web browser, however on my android it will not receive the data from localStorage.getItem('visittime') to detect time and compare for deletion
- $( document ).on( "pagecreate", function() {
- var now = new Date().getTime(),
- storagedate = localStorage.getItem('visittime');
- if(storagedate){
- var diff = now - storagedate;
- if(diff > 60000){
- localStorage.removeItem('visited');
- localStorage.removeItem('visittime');
- }
- }
- var yetVisited = localStorage.getItem('visited');
- if (!yetVisited) {
- $(".welcomewindow").delay(1500).fadeIn("300", function(){
- $(".welcome").css({"margin-left":leftPos,"width":welcomeSetwidth}).fadeIn("300") ;
- });
- $(".welcomeClose").on("click",function(e){
- $(".welcomeshield").fadeOut("300");
- $(".welcome").fadeOut("300");
- localStorage.setItem('visited','yes');
- localStorage.setItem('visittime', new Date().getTime());
- });
- }
- }
-
I saw people having somewhat similar issues that resolved it by changing the location of their script to be called before JQM loads or on mobileinit. I haven't been able to figure this out.