MahmoudS MahmoudS - 7 months ago 38
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 ?


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:

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