jsReq

I wanted to tell the user that they need JavaScript, but obviously only if they don’t already have it enabled.
The following is a very crude script which uses the very fact that JS is available to hide the requirement notice…

HTML:

  1. <!– "jsReq" - Jez McKean (jazzle.co.uk) 2006-04-24 */ –>
  2. <div class=“important” id=“jsRequiredDiv”>
  3.  <span class=“error”>Warning!</span>
  4.  You need to have javascript enabled to use this page.
  5. </div>

JS:

  1. function removeElementById(eleId) {
  2.  eleId = document.getElementById(eleId);
  3.  if (eleId.parentNode && eleId.parentNode.removeChild) {
  4.   eleId.parentNode.removeChild(eleId);
  5.  }
  6. }
  7. removeElementById(“jsRequiredDiv”);

Comments are closed.