Using Enhanced <SCRIPT> Tags for Includes

Article translations Article translations
Article ID: 224963
Expand all | Collapse all


Microsoft Internet Information Services (IIS) version 5.0 adds many new Active Server Pages (ASP) capabilities. This article describes how to use the new <SCRIPT> tag syntax to include ASP code in another page.

More information

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Previous versions of IIS allowed an ASP page to include the contents of another file using code similar to the following:
<!--#include file="FILE1.INC"-->
<!--#include virtual="/folder/FILE2.INC"-->
IIS 5.0 has extended the server-side <SCRIPT> tag to include a new SRC attribute as an alternative method to include another page. The new syntax may then look similar to the following:
All code in the included page appears to the scripting engine as though it were between the <SCRIPT> and </SCRIPT> tags. Therefore, unlike the #include directive, your included page should consist of raw code only.
For example, consider the following #include statement:
<!--#include file=""-->
This statement would need to include a page similar to the following:
  For X = 1 To 5
    Response.Write "<p>Howdy!</p>"
Now consider the following <SCRIPT> statement:
This page would need to include a page similar to the following:
For X = 1 To 5
  Response.Write "<p>Howdy!</p>"
The <SCRIPT> example is treated by ASP as though the parent page contains the following syntax:
For X = 1 To 5
  Response.Write "<p>Howdy!</p>"
Note: No actual code should placed between the <SCRIPT> and </SCRIPT> tags in the parent page, as it will be ignored.
The SRC attribute can use either relative or virtual paths, as shown in the following table:
Collapse this tableExpand this table
Path StyleExample Syntax
The following ASP code demonstrates how to use the new <SCRIPT> syntax to mix server-side and client-side scripting.
  1. Save the following ASP page as "ScriptTest.asp" to a Web folder with Script Access enabled:
    <title>Enhanced SCRIPT Example</title>
    <h2 align="center">Enhanced SCRIPT Example</h2>
    <p align="center">
    <form method="GET" name="objForm"
      <input type="text" name="Message">
      <input type="submit" value="Submit">
    <SCRIPT LANGUAGE="JavaScript">
    <!--#include file=""-->
  2. Save the following code as "" to the same folder:
    Dim strMessage
    strMessage = Request.QueryString("Message")
    If strMessage <> "" Then
      Response.Write vbCrLf & "<script for=""window"" event=""onLoad"" language=""JavaScript"">"
      Response.Write vbCrLf & "objForm.Message.value = '" & strMessage & "';"
      Response.Write vbCrLf & "showMessage('" & strMessage & "');"
      Response.Write vbCrLf & "</script>"
    End If 
  3. Next, save the following code as "" to the same folder:
    function showMessage(strText) {
    • When you first browse "ScriptTest.asp," the form is displayed and the client-side function is not called.
    • When you submit text to the page, the server-side script outputs another client-side function that displays the submitted text in the form's input box and in a pop-up window.


Article ID: 224963 - Last Review: June 22, 2014 - Revision: 3.0
kbhowto KB224963
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from