http://developer.netscape.com/docs/index.html
Not all browsers support JavaScript, so in order to allow for reasonable display functions on non-JavaScript compatible browsers, most HTML pages will include JavaScript code inside of an HTML comment as in:<script language="JavaScript"> .... some JavaScript code </script>
The <!-- and // --> characters delimit HTML comments. It is thus legal for JavaScript source code to be "inside" of HTML comments and still recognized as JavaScript source code.<script language="JavaScript"> <!-- ... some JavaScript code // --> </script>
It is perfectly legal to include more than one <script language="JavaScript"> section within a program.
When you write JavaScript code, there are two general classes of JavaScript elements. You can define functions that will be called by other JavaScript code, and you can define in-line code that is executed when the page is loaded. You define a function in a manner similar to:
<script language="JavaScript">
function Function1(Parameter1,Parameter2)
{
...
}
function Function2(Parameter1,Parameter2)
{
...
}
</script>
You can define in-line JavaScript in the same manner by just defining elements
outside of functions:
<script language="JavaScript">
Function1("p1","p2")
Function2("p3","p4")
</script>
The last place that you can include JavaScript code is as event handlers
for other HTML elements. This allows you to do things like submit
a form when a user clicks on a hypertext link, change the graphics that
are displayed when the mouse is over a picture, or reload the page after
a certain amount of time has expired. The specifics of these actions
are beyond the scope of this introduction, but the general format of a
JavaScript event handler is:
The JavaScript code in this type of example is usually a simple call to a JavaScript function that you have previously defined.<a href="..." onclick="JavaScript code"> ... </a>
<html>
<head>
...
</head>
<body>
<script language="JavaScript"><!--
function SubmitFn(x)
{
document.forms[0].SELID.value = x
document.forms[0].submit()
return false
}
// --></script></p>
<form method="POST">
<input type="hidden" name="SELID">
...
<p><a href="1234" onclick="return SubmitFn('1234')">link 1234</a></p>
<p><a href="5678" onclick="return SubmitFn('5678')">link 5678</a></p>
</form>
</body>
</html>
There are several parts to this example:
This function can actually exist anywhere in the HTML source code. The customary place is to include JavaScript functions as the first statements after the <body> tag.
to retrieve the value of this variable so that your program can sense which link was followed.PL_GETVAR variable from 'SELID' else variable = ''