酷!學園

技術討論區 => 網頁技術 => 主題作者是: 夢無痕 於 2010-04-16 14:25

主題: 讓blogger可以貼html程式碼
作者: 夢無痕2010-04-16 14:25
我想讓我的google的blogger可以貼程式碼
就像這個http://keikoblog.blogspot.com/2009/03/blog.html (http://keikoblog.blogspot.com/2009/03/blog.html)這樣
我已經在blooger範本輸入了
代碼: [選擇]
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'></script>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>

然後貼一個文章測試
代碼: [選擇]
<pre class="brush: html;">
<html><body>
test
</body></html>
</pre>
為什顯示卻只有這樣
test
照常理講因該要顯示
<html><body>
test
</body></html>

除非要
轉換成
&lt;html&gt;&lt;body&gt;
test
&lt;/body&gt;&lt;/html&gt;
才可以正常顯示
我有提供我的網址
http://a-rong-go.blogspot.com/2010/04/blog.html
請問有高手可以為我解惑嗎


主題: 回覆: 讓blogger可以貼html程式碼
作者: see7di2010-05-02 22:34
因为在发贴的时候使用了php的script_tag函数把html的meta标签都给过滤掉了,这是错误的,同样的错误我在yahoo的blog也见过,这种过滤是错误的
解决方法很简单,只需要使用htmlspecialchars函数即可