日期:2014-05-17  浏览次数:20915 次

如何输出HTML源码?
现有这样的asp代码
htmlstr=server.execute( "a.asp ")
response.write   htmlstr

这样的话,将会编译HTML源码

但本人想将源码输出,而不被编译呢!
试这样
response.write   server.HTMLENCODE(htmlstr)也不行
为什么呢?是不是server.HTMLENCODE只对一行有效?


------解决方案--------------------
放到一个框里textarea
------解决方案--------------------
从客户端读取的ASP文件都是解释过的,不可能输出程序源码
你只能说输出HTML代码,这样可以做到

function ReadBody(RemoteFileUrl)
Dim Retrieval
On Error Resume Next
Set Retrieval = Server.CreateObject( "Microsoft.XMLHTTP ")
With Retrieval
.Open "Get ", RemoteFileUrl, False, " ", " "
.Send
ReadBody = .ResponseBody
End With
Set Retrieval = Nothing
End function
------解决方案--------------------
<%
Function inHTML(str)
Dim sTemp
sTemp = str
inHTML = " "
If IsNull(sTemp) = True Then
Exit Function
End If
stemp=Replace(stemp, CHR(38), "&#38; ")
sTemp = Replace(sTemp, "& ", "&amp; ")
sTemp = Replace(sTemp, " < ", "&lt; ")
sTemp = Replace(sTemp, "> ", "&gt; ")
stemp=Replace(stemp, CHR(39), "&#39; ")
stemp= Replace(stemp, CHR(32), "&nbsp; ")
sTemp = Replace(sTemp, Chr(34), "&quot; ")
stemp = Replace(stemp, CHR(13), " ")
stemp = Replace(stemp, CHR(10), " <br> ")
inHTML = sTemp
End Function
'如果你的html内容在某一变量str中
response.write inhtml(str) '运行看看效果
%>