如何检测用户浏览器中的JavaScript或Cookies是否已禁用并通知他
有帮助吗?
最佳答案
要检查Cookie,您可以使用:
function checkCookie(){
var cookieEnabled = navigator.cookieEnabled;
if (!cookieEnabled){
document.cookie = "testcookie";
cookieEnabled = document.cookie.indexOf("testcookie")!=-1;
}
return cookieEnabled || showCookieFail();
}
function showCookieFail(){
// do something here
}
// within a window load,dom ready or something like that place your:
checkCookie();
为了检查JavaScript,请使用带有某些消息的
<noscript>
标记