下载地址:http:///p/syntaxhighlighter/
附一个小例子说一下 textarea 和 pre 的区别
复制代码 代码如下:
<html>
<head>
<title>高亮测试</title>
<link type="text/css" rel="stylesheet" href="Styles/SyntaxHighlighter.css"/>
<script language="javascript" src="Scripts/shCore.js"></script>
<script language="javascript" src="Scripts/shBrushXml.js"></script>
</head>
<body>
<textarea name="code" class="xml" rows="15" cols="100">
程序源代码放在这儿afds
dp.SyntaxHighlighter.HighlightAll('code');
dp.SyntaxHighlighter.HighlightAll('code2');
请注译掉这二句查看效果,注意 textarea 和 pre 的分别。pre中的 《 号需要转译,要不然就原样输出了,在高亮代码没有生效的情况下。
<h1>adsfadfadf</h1>
-------------------
<h1>adsfadfadf</h1>
</textarea>
<pre name="code2" class="xml" rows="15" cols="100">
程序源代码放在这儿afds
dp.SyntaxHighlighter.HighlightAll('code');
dp.SyntaxHighlighter.HighlightAll('code2');
<h1>adsfadfadf</h1>
-------------------
<h1>adsfadfadf</h1>
</pre>
<script class="javascript">
dp.SyntaxHighlighter.HighlightAll('code');
dp.SyntaxHighlighter.HighlightAll('code2');
</script>
</body>
</html>