在jQuery移动应用程序中将参数从一个页面传递到另一个页面

我正在使用PhoneGap构建一个jQuery移动应用程序。 我必须通过使用jQuery mobile传递一些关键页面的参数来打开一个新页面。 为此我尝试使用本地存储,如下所示:

$("li").click(function(){ console.log("hi"); var index = $(this).index(); console.log("index"+ index); window.localStorage.setItem("date",userArray_date[index] ); window.localStorage.setItem("title",userArray_title[index] ); window.location.href='mypage.html'; }); 

在另一个页面上,我检索了这样的值:

 var display_date = window.localStorage.getItem("date"); var display_title = window.localStorage.getItem("title"); $("#Date_Leaf").append(display_date); $("#Title_Leaf").append(display_title); 

这在Android手机上正常工作,但在Windows 7手机上不起作用。 任何人都可以告诉我,我错在哪里吗?

http://docs.phonegap.com/en/2.0.0/cordova_storage_storage.md.html#localStorage

尝试在onDeviceReady函数中使用本地存储

我们使用PhoneGap deviceready方法进行localstorage,它运行正常。 喜欢:

 document.addEventListener("deviceready", myMethod, false); function myMethod(){ $("li").click(function(){ var index = $(this).index(); console.log("index"+ index); window.localStorage.setItem("date",userArray_date[index] ); window.localStorage.setItem("title",userArray_title[index] ); window.location.href='mypage.html'; });} and On mypage.html: document.addEventListener("deviceready", page2Method, false); function page2Method(){ var display_date = window.localStorage.getItem("date"); var display_title = window.localStorage.getItem("title"); }