"I work at a major financial services company," writes Seth. "We have a public site that requires JavaScript be enabled. When it's not, the visitor is redirected to an error page that explains the website's requirements."

Definitively determining whether someone has JavaScript turned on or not can be a pretty challenging task, but fortunately, Seth's colleagues developed a bulletproof method to figure this out. They used JavaScript.

function javascriptEnabled(){
     return true;
}

Clearly, if that function is successfully called, then JavaScript must be enabled. Like the isComputerOn() method that was (allegedly) part of the BeOS API, if it doesn't return true, then clearly, it's off. So, by applying this logic later on in the code, Seth's colleagues came up with this:

function validateSettings(){

  if(!javascriptEnabled()){
    location.href="no_js.htm";
  }
  ...
}

Seth added, "To their credit... err, I think... they said that they didn't realize JavaScript could be disabled in their browser. They tested it by having javascriptEnabled return false."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!