Javascript: Where it fits within the HTML

Javascript is typically placed within three areas of a web page:

Below is a code sample which illustrates several techniques:

<html>

<head>

<script language="javascript">
<!--

function f_timer()
{
imageidx ++ ;
if (imageidx==8)
  {
  imageidx=0
  } ;
}

// -->
</script>

</head>

<body>
<form>

Paragraph 1 : This is some sample text located in the body of the page.<br>
This example illustrates the ability to embed Javascript calls within the body of a form.

<script language="javascript">
<!--
document.write("<hr>" + "This was written by Javascript" + "<hr>");
// -->
</script>

Paragraph 2 : This is some sample text located in the body of the page.<br>
This example illustrates the ability to embed Javascript calls within the body of a form.

<script language="javascript">
<!--
document.write("<h2>" + "This was written by Javascript also" + "</h2>");
// -->
</script>

Paragraph 3 : This is some sample text located in the body of the page.<br>
This example illustrates the ability to embed Javascript calls within the body of a form.

</form>
</body>

<script>
<!--
timerID = setTimeout("f_timer()", 1000);
//-->
</script>

</html>




Back to top
email ... js99@rocket99.com

Copyright 1998-2000 © Citisoft, Inc. All Rights Reserved.