MahmoudS MahmoudS - 15 days ago 5
Javascript Question

How to detect that JavaScript and/or Cookies are disabled?

I want to make a script that checks if the JavaScript or Cookies are disabled in the user's browser and notify him
any help ?

Answer

For checking cookies you can use:

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();

And for checking JavaScript use a <noscript> tag with some kind of message inside