Javascript should totally not be a problem but yes it would be good form to escape it. You can also add a 'noscript' tag. Here is a simple example.
- Code: Select all
<script type="text/javascript">
<!--
document.write("Hello World!")
-->
</script>
<noscript>Your browser does not support JavaScript!</noscript>
Another option is to put your javascript in another file, like myscript.js. This can clean up your page code very nicely, and works especially well if you use the same script on multiple pages.
- Code: Select all
<script type="text/javascript" src="myscript.js">
You should begin to invest some time into learning PHP along with your Javascript and HTML. Purely for multi-page layout purposes there is nothing better than PHP's "include". As PHP is "server side" as opposed to Javascript's "client side" you can also replace some Javascript functions in which you would like to have more control over... Date & Time based scripts, randomizers and content generation being the most prominent. Javascript is still preferable to handle visual effects like rollovers and mouseovers.