Include Inline JavaScript code

To include inline JavaScript code, place JavaScript code inside the <script> element directly, as
follows:
<script type=”text/javascript”>
function sayHi(){
alert(“Hi!”);
}
</script>

When using inline JavaScript code, keep in mind that you cannot have the string “</script>” anywhere
in your code. For example, the following code causes an error when loaded into a browser:
<script type=”text/javascript”>
function sayScript(){
alert(“</script>”);
}
</script>

Because of the way that inline scripts are parsed, the browser sees the string “</script>” as if it
were the closing </script> tag. This problem can be avoided easily by escaping the “/” character,
as in this example:
<script type=”text/javascript”>
function sayScript(){
alert(“<\/script>”);
}
</script>