Transfer scripts to browsers in ASP

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.