LocalStorage无法使用Windows 8 Phone HTML 5项目模板 [英] LocalStorage not working with Windows 8 Phone HTML 5 project template

查看:72
本文介绍了LocalStorage无法使用Windows 8 Phone HTML 5项目模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HTML 5制作Windows 8手机应用。

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

我使用localStorage保存一些小值,如下面的代码所示,我测试了我的所有浏览器中的代码都运行得很好,然后我创建了一个新的HTML 5项目,并将我的代码添加到项目中并运行了应用程序。

I am using localStorage for saving some small values as shown in the code below, I have tested my code in all browsers and it was working perfectly fine, then I created a new HTML 5 project and added my code to the project and ran the application.

在下面的代码中,我怀疑localStorage在这里不起作用,我想知道为什么?

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

我是如何得出这个结论的?

1 - 我尝试在localStorage.selected_category =cow之前和之后发出警报;在这里显示第一个警报,但第二个警报未显示。

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

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

2 - 接下来我尝试删除行本身,然后我的window.location.href ='animals。 html';之前没有工作现在工作。

2 - Next I tried removing the line itself and then my window.location.href = 'animals.html';which was not working earlier now worked.

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

这可能是什么问题?我的整个应用程序可以在Firefox,Chrome甚至是Internet Explorer 10上顺利运行。

What could be the problem here ? My entire app works smoothly with Firefox, Chrome and even with Internet Explorer 10.

请分享您的想法。如何使localStorage在我的HTML 5 Windows 8 Phone应用程序上运行?

Please share your thoughts on this. How do I make the localStorage work on my HTML 5 Windows 8 Phone app ?

注意:

我使用以下js
- jquery.min.js& jquery.mobile-1.2.0.min.js

推荐答案

我在我看到完全相同的行为Windows 8 phonegap应用程序。只有在使用jquery mobile时才会出现此问题。你可以尝试在没有jquery mobile的情况下运行你的应用程序吗?

I'm seeing the exact same behavior in my windows 8 phonegap app. The problem only occurs when using jquery mobile. Could you please try to run your app without jquery mobile?

我删除jquery移动localstorage工作正常。

As soon as I remove jquery mobile localstorage is working just fine.

这篇关于LocalStorage无法使用Windows 8 Phone HTML 5项目模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆