How to detect that JavaScript and/or Cookies are disabled?
jQuery detecting cookies enabled
我尝试了两种解决方案,但即使我将禁用设置为Cookie,IE仍会对我忠诚。
请帮忙。
答案 0 :(得分:0)
我用过这个:
function areCookiesEnabled() {
try {
document.cookie = 'cookietest=1';
var cookiesEnabled = document.cookie.indexOf('cookietest=') !== -1;
document.cookie = 'cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT';
return cookiesEnabled;
} catch (e) {
return false;
}
}
来自Modernizr图书馆