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