1. You can use download behavior to download and then display with InnerHTML features.
Specific steps:
<span id= "Demo" src= "Demo.htm"
Style= "Behavior:url (#default #download)" ></span>
<SCRIPT>
function Window.onload () {
Demo.startdownload (Demo.src,fndownload)
}
function Fndownload (osource) {
Demo.innerhtml=osource
}
</SCRIPT>
The code for the called page demo.htm.
<span style= "Color:red;font:bold 12px Tahoma" >
Testing Demo test test demo demo</span>
Note: In this example, the object with the ID demo must set its default behavior to download.
2.script. It is important to note that the include.js can no longer contain <script> and </script> the extension is optional, all content must be through write (), Wirteln (), InnerHTML, innertext, outerHTML or outertext output display. code example:
<script src= "Include.js" ></script>
<script language= "JavaScript" src= "http://www.newsccn.com/count.php?contentid={$contentid}" ></script >
3.iframe. There is no need to explain this, if you have any questions, please chapter sixth of the first part. code example:
<iframe src= "Index.asp" ></iframe>
4.Object (scriptlets component). code example:
With scroll bar <br>
<object data= "index.asp" type= "text/html" width=400 height=300></object>
<br> No scroll bar <br>
<object style= "border:0px" type= "Text/x-scriptlet" Data= "index.asp" width=400 height=300></object>
5.SSI (server-side included). code example:
<!--#include file= "index.html"-->
<!--#include virtual= "/index.html"-->
6.server.transfer,server.execute (Method of ASP object). code example:
Server.Execute ("index.asp")
Server.Transfer ("index.asp")
7.FSO (FileSystemObject, file read/write component) code example:
<%
Tf=server.mappath ("index.asp")
Set Fs=server.createobject ("Scripting.FileSystemObject")
Set Ts=fs.opentextfile (TF)
Do while (Ts.atendofstream<>true)
Response.Write (Ts.readline)
Loop
Ts.close
%>
8.XMLHTTP components. code example:
<script for= "window" event= "onload" >
With (new ActiveXObject ("Microsoft.XMLHTTP")) {
Open ("Get", Demo.src,false, "", "")
Send ()
Demo.innerhtml=responsetext
}
</script>
<span id= "Demo" src= "Demo.htm" ></span>
Note that the destination file is best saved with Unicode or UTF-8 encoding, otherwise the Double-byte text in the destination file will become garbled. Of course, you can use the following function to handle the returned responsetext, but this is less efficient, the file is not recommended when large. XMLHTTP This method can also be used in background programs.
<script language=vbscript>
function Bytes2bstr (VIN)
Strreturn = ""
For i = 1 to LenB (VIN)
Thischarcode = ASCB (MidB (vin,i,1))
If Thischarcode < &h80 Then
Strreturn = Strreturn & Chr (Thischarcode)
Else
Nextcharcode = ASCB (MidB (vin,i+1,1))
Strreturn = Strreturn & Chr (CLng (thischarcode) * &h100 + CInt (nextcharcode))
i = i + 1
End If
Next
Bytes2bstr = Strreturn
End Function
</script>
9.HTC (HTML Component, to be covered in the next chapter).
(1) contains the page code.
<span style= "Behavior:url (INDEX.HTC)" ></span>
(2) The code that contains the page INDEX.HTC.
<public:attach event= "Oncontentready" onevent= "Loadit ()"/>
<script>
function Loadit () {
insertAdjacentHTML ("Afterbegin", include.innerhtml)
}
</script>
<XMP id= "include" >
Content included
<a href=http://www.flash8.net>flash8</a>
</xmp>
Special Tips
This example code runs as shown in Figure 2.4.5, and the text displayed on the page is demo.htm page.
Graph 2.4.5 Download Behavior application effect
Special Notes
The role of download behavior is to download the file and notify a specified callback function after the download completes, which has only one startdownload method:
Startdownload downloads the specified file, which takes two parameters, the first parameter is the file address of the specified download, and the second parameter is a pointer to the function of the code to be executed after the download is complete. If the called function is written in VBScript script, you need to use the GETREF function to get a pointer to this callback function.