Implementation of script transfer to browser in ASP

Source: Internet
Author: User
Tags date time and date client
Although ASP is primarily used to create and process server-side scripts, it is possible to use it to generate client script that is processed by the client browser to extend its utility. You can write server-side scripts by combining script commands that are delivered to the browser.

This can be done by combining client script enclosed by HTML annotations and server-side scripts enclosed by delimiters:

SCRIPT language= "VBScript" >

!--

Client Script

% Server Script%>

Client Script

% Server Script%>

Client Script

...

-->

/script>

Using this feature of the scripting language, you can create exciting applications. For example, the following script will generate a subroutine of the client script that runs 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," "%= servertime%>."

Case 1

MSG = "welcome! Today's date is%= serverdate%>.

Case 2

MSG = "Hi, the"%= servertime%> and the date is%= serverdate%>.

End Select

document.write MSG

End Sub


serveinfo<%= i%> ()


file://-->

/script>


%

Next

%>

In the above script, ASP retrieves time and date information on the server, and then loops through several cycles to generate subroutines that run on the user's Web server. Each client subroutine presents a random selection of greetings, displaying time and date information.

This script can be extended, for example, to retrieve and submit configuration information to a specified client script or component, such as an ActiveX control. The flexibility to use this scripting technique can also speed up WEB server processing and returning requests for user information.



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.