Categories
Code

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:
[code lang=”html”]

Warning!
You need to have javascript enabled to use this page.

[/code]

JS:
[code lang=”JavaScript”]
function removeElementById(eleId) {
eleId = document.getElementById(eleId);
if (eleId.parentNode && eleId.parentNode.removeChild) {
eleId.parentNode.removeChild(eleId);
}
}
removeElementById(“jsRequiredDiv”);
[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.