Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Cookie在symbian中不起作用_Jquery_Jquery Ui_Jquery Mobile_Cordova_Phonegap Plugins - Fatal编程技术网

Jquery Cookie在symbian中不起作用

Jquery Cookie在symbian中不起作用,jquery,jquery-ui,jquery-mobile,cordova,phonegap-plugins,Jquery,Jquery Ui,Jquery Mobile,Cordova,Phonegap Plugins,大家好,我正在使用phonegap开发一个应用程序。我的应用程序在android和blackberry上运行良好,但在symbian上无法运行 在其中一个页面上,我设置cookies,如: $.cookie("userName", userName, { path: '/' }); $.cookie("currentTime", currentTime, { path: '/' }); 在另一个页面上,我尝试访问它,如下所示: alert($.cookie('userName')); 但

大家好,我正在使用phonegap开发一个应用程序。我的应用程序在android和blackberry上运行良好,但在symbian上无法运行

在其中一个页面上,我设置cookies,如:

 $.cookie("userName", userName, { path: '/' });
 $.cookie("currentTime", currentTime, { path: '/' });
在另一个页面上,我尝试访问它,如下所示:

alert($.cookie('userName'));
但该警报显示为“空”,尽管相同的代码在android和blackberry上运行良好。

Symbian支持Cookie吗?

尝试另一种JS代码进行测试

// Function that create a cookie and set its value
function setCookie(name, value, expiryDate) {
document.cookie = escape(name) + "=" + escape(value) + "; path=/" +
    ((expiryDate == null) ? "" : "; expires=" + expiryDate.toGMTString());
}


// Function that gets the cookies value
function getCookie(name) {
var cookieName = name + "=";
var documentCookie = document.cookie;
var start, end;

if(documentCookie.length > 0) {
    start = documentCookie.indexOf(cookieName);
    if(start != -1) {
        start += cookieName.length;
        end = documentCookie.indexOf(";", start);
        if(end == -1) end = documentCookie.length;

        return unescape(documentCookie.substring(start, end));
    }
}
return null;
}
你可以将cookie设置为

setCookie('cookieName', value, cookieExpiry);
并获得它的价值

getCookie('cookieName')

诺基亚的WGZ小部件不支持cookies,但作为一种解决方法,我开始使用小部件,但好像它是一个本地存储对象;这里有一个片段。。。我希望有帮助

干杯

if (!window.localStorage) {

if(typeof(widget)==='undefined')
{
//alert('working with an OS5 blackberry');
 window.localStorage = {
getItem: function (sKey) {
  if (!sKey || !this.hasOwnProperty(sKey)) { return null; }
  return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
},
key: function (nKeyId) { return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/, "").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[nKeyId]); },
setItem: function (sKey, sValue) {
  if(!sKey) { return; }
  document.cookie = escape(sKey) + "=" + escape(sValue) + "; path=/";
  this.length = document.cookie.match(/\=/g).length;
},
length: 0,
removeItem: function (sKey) {
  if (!sKey || !this.hasOwnProperty(sKey)) { return; }
  var sExpDate = new Date();
  sExpDate.setDate(sExpDate.getDate() - 1);
  document.cookie = escape(sKey) + "=; expires=" + sExpDate.toGMTString() + "; path=/";
  this.length--;
},
hasOwnProperty: function (sKey) { return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie); }
};
window.localStorage.length = (document.cookie.match(/\=/g) || window.localStorage).length;
}
else
{ 
//alert('working with widgets');
window.localStorage={
 getItem: function (sKey) {
    return widget.preferenceForKey(sKey);
},

setItem: function (sKey, sValue) {
  widget.setPreferenceForKey(sValue, sKey);
},
length: 0,
removeItem: function (sKey) {
   widget.setPreferenceForKey(null,sKey );
},
hasOwnProperty: function (sKey) { 
     return widget.preferenceForKey(sKey)!==null;
}
};
}
}