Although ASP is mainly used to create and process server scripts, it can still be used to generate client scripts processed by the client browser to extend its utility. You can write server scripts by combining the script commands sent to the browser.
This can be done by combining client scripts enclosed by HTML comments and server scripts enclosed by delimiters:
<Script language = "VBScript">
<! --
Client script
<% Server script %>
Client script
<% Server script %>
Client script
...
-->
</SCRIPT>
With this feature in scripting, you can create exciting applications. For example, the following script will generate a subprogram of the customer script running on the user's web browser.
<%
Servertime = Time
Serverdate = Date
For I = 1 to 4
Randomize
Greetcondition = int (RND * 3)
%>
<Script language = "VBScript">
<! --
Sub serveinfo <% = I %> ()
Select case <% = greetcondition %>
Case 0
MSG = "hello, the time is <% = servertime %> ."
Case 1
MSG = "Welcome! Today's date is <% = serverdate %> ."
Case 2
MSG = "Hi, the time is <% = servertime %> and the date is <% = serverdate %>.
End select
Document. Write msg
End sub
Serveinfo <% = I %> ()
// -->
</SCRIPT>
<%
Next
%>
In the above script, ASP retrieves time and date information on the server, and then generates a subroutine running on the user's Web server through several cycles. Each client subroutine presents a randomly selected greeting to display the time and date information.
This script can be expanded. For example, you can retrieve and submit the configuration information to a specified client script or component, such as an ActiveX control. The flexible use of this script writing technique can also speed up the web server to process and return user information requests.