已加载的库:
<script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui.min.js"></script>
<script type="text/javascript" src='/js/jquery.session.js'></script>
<script type="text/javascript" src="/js/functions.js"></script>
Chrome中的:我今天早上有以下经历:
$.session.set('auth',response.username);
throws Uncaught TypeError:无法读取未定义
的属性'set'我用:
if($.session.get('auth') !== undefined){
$.getScript('script.js');
}
和script.js没有加载 这个刚刚开始在Chrome中发生。 在其他浏览器中工作 - 甚至是铬。 Ran升级(Ubuntu Trusty), 现在铬也不起作用。 适用于Windows上的Chrome浏览器
其他人在一夜之间就像这样打破了他们的代码吗?
更新:如果我在Chrome中隐身,则此问题会消失,我的网站也能正常运行。在我的Google帐户设置中必须是某些内容吗?
任何人都有类似的经历吗?
答案 0 :(得分:0)
我只是将设置重置为出厂默认设置 - 诀窍。
答案 1 :(得分:0)
请试试这个..
我试过了,它为我工作..
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="js/jquery.session.js"></script>
<script type="text/javascript">
// To Read
$(function () {
//Set the value to session
$.session.set("userName", "This is session value");
//Get the value to session
alert($.session.get("userName"));
});
</script>
</head>
这是jQuery.session.js脚本......
(function ($) {
$.session = {
_id: null,
_cookieCache: undefined,
_init: function ()
{
if (!window.name) {
window.name = Math.random();
}
this._id = window.name;
this._initCache();
// See if we've changed protcols
var matches = (new RegExp(this._generatePrefix() + "=([^;]+);")).exec(document.cookie);
if (matches && document.location.protocol !== matches[1]) {
this._clearSession();
for (var key in this._cookieCache) {
try {
window.sessionStorage.setItem(key, this._cookieCache[key]);
} catch (e) {
}
;
}
}
document.cookie = this._generatePrefix() + "=" + document.location.protocol + ';path=/;expires=' + (new Date((new Date).getTime() + 120000)).toUTCString();
},
_generatePrefix: function ()
{
return '__session:' + this._id + ':';
},
_initCache: function ()
{
var cookies = document.cookie.split(';');
this._cookieCache = {};
for (var i in cookies) {
var kv = cookies[i].split('=');
if ((new RegExp(this._generatePrefix() + '.+')).test(kv[0]) && kv[1]) {
this._cookieCache[kv[0].split(':', 3)[2]] = kv[1];
}
}
},
_setFallback: function (key, value, onceOnly)
{
var cookie = this._generatePrefix() + key + "=" + value + "; path=/";
if (onceOnly) {
cookie += "; expires=" + (new Date(Date.now() + 120000)).toUTCString();
}
document.cookie = cookie;
this._cookieCache[key] = value;
return this;
},
_getFallback: function (key)
{
if (!this._cookieCache) {
this._initCache();
}
return this._cookieCache[key];
},
_clearFallback: function ()
{
for (var i in this._cookieCache) {
document.cookie = this._generatePrefix() + i + '=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
this._cookieCache = {};
},
_deleteFallback: function (key)
{
document.cookie = this._generatePrefix() + key + '=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
delete this._cookieCache[key];
},
get: function (key)
{
return window.sessionStorage.getItem(key) || this._getFallback(key);
},
set: function (key, value, onceOnly)
{
try {
window.sessionStorage.setItem(key, value);
} catch (e) {
}
this._setFallback(key, value, onceOnly || false);
return this;
},
'delete': function (key) {
return this.remove(key);
},
remove: function (key)
{
try {
window.sessionStorage.removeItem(key);
} catch (e) {
}
;
this._deleteFallback(key);
return this;
},
_clearSession: function ()
{
try {
window.sessionStorage.clear();
} catch (e) {
for (var i in window.sessionStorage) {
window.sessionStorage.removeItem(i);
}
}
},
clear: function ()
{
this._clearSession();
this._clearFallback();
return this;
}
};
$.session._init();
})(jQuery);
请告诉我这段代码是否适合你。