2017-02-14 34 views
1

How to detect that JavaScript and/or Cookies are disabled?检测如果Cookie在IE 11使用JS

jQuery detecting cookies enabled

我都尝试解决方案支持的,但仍IE返回真我,即使我设置残疾人饼干。

请帮忙。

+0

的可能的复制[?如何检测中的JavaScript和/或Cookie已停用(http://stackoverflow.com/questions/4603289/how-to-detect-that-javascript-and-or-cookies-are-disabled) – Pineda

+1

我曾经有过类似的问题。发现如果我在本地打开文件,它不会在IE11中阻止Cookie。 – Tallerlei

回答

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