in browser , there is options that web site users can disable scripts that consequently this may be disable masks and other codes write with jquery and another scripts , and there for web site will have exception or may be web site hack. how to safe web site with these options? thanks
2 Answers
You can't stop users from disabling javascript if they don't want to turn it on.
Your only recourse is to require javascript before allowing them to use your website.
This can be done by wrapping everything in a "display: none", eg.
<div id="content" style="display: none">
PAGE CONTENT HERE
</div>
And a message:
<div id="javascriptrequired">You need javascript to use this website.</div>
And then use javascript to set the display back on, and turn the message off:
<script>
$("#content").css("display: block;"); // assuming you have jquery
$("#javascriptrequired").css("display: none;"); // turn javascript message off
</script>
3 Comments
Arxeiss
Or you can use
<noscript> tag http://www.w3schools.com/tags/tag_noscript.aspRajesh J Advani
Good answer. Of course this is easily fixed. The user could use firebug to turn the display back to block, but it's better than nothing.
ronalchn
Although if I really cared (not that I do - in fact, I try to make javascript optional) and was vindictive, I could make every link a javascript link to annoy javascript-blockers.