<%@ Language=JavaScript %> Default Script Language: JavaScript

Default Script Language: JavaScript (or JScript)

<% var strMsg = "Hello World"; //Local Variable. //----------------------------------------- function displayLoop() { //----------------------------------------- var intLoop = 5; //Global variable. for ( x=0; x < intLoop; x++ ) { Response.Write( x + ". Hello World
" ); } } %>

Next, call JavaScript's displayLoop() method from ASP.

<% displayLoop() %>

Note: intLoop is local so we would get an error if we referenced it here. strMsg is global and can be referenced: <%= strMsg %>.