LocalStorage not working with HTML 5 Phone 8 project template

I am making a Windows 8 Phone app using HTML 5.

I am using localStorage to store small values ​​as shown in the code below, I tested my code in all browsers and it worked fine, then I created a new HTML 5 project and added my code to the project and run the application.

In the following code, I suspect localStorage is not working here and I am wondering why ?? !

$("#cow_btn").click(function(){
    localStorage.selected_category = "cow";
    window.location.href = 'animals.html';
}); 

      

How did I come to this conclusion?

1 - I've tried giving warnings before and after localStorage.selected_category = "cow"; line, the first warning was shown here, but the second warning was not shown.

$("#cow_btn").click(function(){
    alert("hello1");
    localStorage.selected_category = "cow";
    alert("hello1");
    window.location.href = 'animals.html';
}); 

      

2 - Then I tried to remove the line and then my window.location.href = 'animals.html' which didn't work before now worked.

$("#cow_btn").click(function(){
    window.location.href = 'animals.html';
}); 

      

What could be the problem? My whole application runs smoothly with Firefox, Chrome and even Internet Explorer 10.

Share your thoughts on this. How do I get localStorage to work with my HTML 5 Windows 8 Phone app?

Note:

I am using the following js - jquery.min.js and jquery.mobile-1.2.0.min.js

+3


source to share


3 answers


I see the same behavior in my phonegap app for Windows 8. The problem only occurs when using jQuery mobile. Could you try running the app without jquery mobile?



As soon as I remove jquery mobile localstorage works fine.

+3


source


localStorage is fully supported in WP8 / IE10. To double check this try this

alert("typeof localStorage=" + typeof window.localStorage);

      



PS. Consistency can help you solve the problem.

Debug Javascript for Windows Phone 8 IE10

+2


source


Windows Phone does not support coding style. Be sure to use the setItem / getItem commands as in WP8 / IE10 localStorage.key =; commands are not even hard-coded, they are W3C standard.

-2


source







All Articles