Hiding your Javascript
Question: Can I add javascript code that will keep an error message from displaying on computers that have javascript disabled?
Joel Benjamin
Answer:You can avoid having your Javascript display as text on browsers that don't support Javascript by making all of your javascripts external to the page. Place them in files with a .js extension and access them like this:
<script type="text/javascript" src="myscript.js"></script>
The script will then only be included when the script tag is recognised.
You could also code it inline like this:
<script type="text/javascript"><!--
javascript code goes here
// --></script>
This method works with current browsers but the standards say that the browsers are supposed to ignore comments so new browsers may ignore your javascript code completely if you use this second method.
The way that the standards say that Javascript should be included inline does not hide the code from browsers that do not understand the script tag.


