Friday, September 5, 2008

JavaScript and Comments

Some older browsers do not recognize JavaScript. These browsers would sometimes display JavaScript
code in the page as if it were part of the contents of the page. Therefore, it is conventional to place
JavaScript code between comment tags as follows:

<script>
<!--
..JavaScript code goes here..
//-->
</script>


Older browsers would just ignore the Javascript code between the <!-- and --> comment tags, while new
browsers would recognize it as JavaScript code. The // just before the end comment tag --> is a JavaScript
comment symbol, and tells the browser not to execute the end comment tag --> as JavaScript. Using
comment tags makes a webpage more accessible to older browsers.