本文介绍了使用Pre在网页中显示文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图像CodeProject一样在网页上显示程序文本.但是,以某种方式我无法获得正确的组合!我尝试了所有4种组合,但都没有结果.秘密是什么?


 <%
CR = hr( 10 )

文字= " <表格边框="  "  1" "   bordercolor =" " #660066"  " >"& CR
文字=文字& " < tr>< td>测试行1</td></tr>"" & CR
文字=文字& " < tr>< td>测试行2</td></tr>"" & CR


        NText = replace(text," <" " & lt;")
        Ntext = replace(Ntext," >" " & gt;")
        Ntext = replace(Ntext," &" " & amp;")
        Ntext = replace(Ntext," "  " ""  & quot;")
        Ntext = replace(Ntext,Chr( 10 ),"  < br>")


%> 
<     边框  ="   1"    bordercolor   ="  >#FF0000"  > 
<   tr  >  <   td  > 
<   b  > 原始无预<  /b  >  <   br  >  <% = text %> 
<  /td  >  <  /tr  > 
<   tr  >  <   td  > 
<   b  > 原始wz前<  /b  >  <   br  >  <   pre  >  <% = text %>  <  /pre  > 
<  /td  >  <  /tr  > 
<   tr  >  <   td  > 
<   b  > 已转换无预<  /b  >  <   br  >  <% = ntext %> 
<  /td  >  <  /tr  > 
<   tr  >  <   td  > 
<   b  > 已转换wz Pre <  /b  >  <   br  >  <   pre  >  <% = ntext %>  <  /pre  > 
<  /td  >  <  /tr  > 
<  /table  >  



rgds,
kfl.

解决方案


Hi,

I try to show the program text in a web page just like CodeProject; however, somehow I just can not get the right combination! I tried all 4 combinations with no result. What is the secret?


<%
CR = chr(10)

Text = "<table border=""1"" bordercolor=""#660066"">" & CR
Text = Text & "<tr><td>test line 1</td></tr>" & CR
Text = Text & "<tr><td>test line 2</td></tr>" & CR


        NText = replace(text, "<", "&lt;")
        Ntext = replace(Ntext, ">", "&gt;" )
        Ntext = replace(Ntext, "&", "&amp;")
        Ntext = replace(Ntext, """", "&quot;")
        Ntext = replace(Ntext, Chr(10), "<br>")


%>
<table border="1" bordercolor="#FF0000">
<tr><td>
<b>Original No Pre</b><br><%=text%>
</td></tr>
<tr><td>
<b>Original wz Pre</b><br><pre><%=text%></pre>
</td></tr>
<tr><td>
<b>Converted No Pre</b><br><%=ntext%>
</td></tr>
<tr><td>
<b>Converted wz Pre</b><br><pre><%=ntext%></pre>
</td></tr>
</table>



rgds,
kfl.

解决方案



这篇关于使用Pre在网页中显示文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:42