用<!-- #include...不能傳ASP參數(shù),這里我們介紹兩種能傳遞ASP參數(shù)并直接讀取的方法。
方法1:
<%
Function getFileContents(strIncludeFile) '函數(shù):讀取包含文件內(nèi)容
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") '調(diào)用FSO對象
Set objText = objFSO.OpenTextFile(Server.MapPath(strIncludeFile),,True)
getFileContents = objText.ReadAll
objText.Close
Set objText = Nothing
Set objFSO = Nothing
End Function
attachurl="index.asp" '讀取網(wǎng)頁
response.write getFileContents(""&attachurl&"")
%>
注意:此方法讀取的網(wǎng)頁不支持utf-8編碼。
方法2:
<%
Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXML.open "GET","http://www.marketingjenius.com/index.asp",false
objXML.send()
response.write(objXML.responseText)
%>
客戶機(jī)接收響應(yīng)是通過XMLHTTP對象的屬性實(shí)現(xiàn)的:
responseText:將返回消息作為文本字符串;
responseBody:將返回消息作為HTML文檔內(nèi)容;
responseXML:將返回消息視為XML文檔,在服務(wù)器響應(yīng)消息中含有XML數(shù)據(jù)時(shí)使用;
responseStream:將返回消息視為Stream對象。
建站咨詢熱線
029-33273980