The example explains how to use JavaScript to call ASP (reproduced)

Source: Internet
Author: User

You may have seen this call method:
<Script language = "JavaScript" src = "XXX. js"> </SCRIPT>
You may have seen:
<! -- # Include file = "XXX. asp" -->

However, you may not have seen the following calls:
<Script language = "JavaScript" src = "XXX. asp? Borid = 5 & page_no = 3 "> </SCRIPT>

Yes, please believe that your eyes are using scripts to call ASP files. In fact, this method has been used quite common on the Internet. If you have been using the Internet, I am sure I know that it provides the function of pasting sub-calls. Think about it. Is the code similar to this?

<Script language = "JavaScript" src = "XXX. asp? Borid = 5 & page_no = 3 "> </SCRIPT>? The result of borid = 5 & page_no = 3 is displayed on the page, which is better than <! -- # Include file = "XXX. asp" --> you can see that the parameter can be passed and the result is displayed. The following is a simple example:

Index.htm:

<HTML>
<Body>
<Script language = "JavaScript" src = "Dy. asp? Num = 1 "> </SCRIPT>
</Body>
</Html>

Dy. asp:

<%
Dim temp
Temp = request. querystring ("num ")
If temp = 1 then
Response. Write "document. Write ('www .baidu.com ');"
Elseif temp = 2 then
Response. Write "document. Write ('www .163.com ');"
Else
Response. Write "document. Write ('www .sohu.com ');"
End if
%>

Note that the output content of ASP files must be written in accordance with JavaScript specifications, such:
Response. Write "document. Write ('www .baidu.com ');"
The output content of your ASP file will be:
Document. Write ('www .baidu.com ');
In this way, the Javascript specification is met. Otherwise, a script error or blank space is displayed !!

 

Http://www.ninedns.com/tech-asp/20074221741154644.html

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.