Up to this point all of the JavaScript Code was in one <SCRIPT> tag, this does not need to be the case.
You can have as many <SCRIPT></SCRIPT> tags as you would like in a document.
The <SCRIPT> tags are processed as they are encountered.
See example below:
<HTML>
<HEAD>
<TITLE>Multiple Script Example</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function largest(x,y)
{var l = x;
if (y>x) l= y;
return l;}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from other browsers
var name = prompt("What's your name","");
// Stop hiding from browsers -->
</SCRIPT>
<H1> Example of Separate Script segments </H1>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from other browsers
// This is where the execution starts
var l = null;
while (true)
{n = prompt("Enter A value, Cancel to end","###");
if (n==null) break; // exit the loop
l = largest(l,n);}
document.write(name + " the largest value was " + l);
// Stop hiding from browsers -->
</SCRIPT>
</BODY>
</HTML>
Run the example
Note: If the script appeas in the <HEAD> section you don't need to worry about hiding it from other browsers