我有生成 XML 的 javascript 代码,并调用该SyntaxHighlighter.all()
方法以突出显示添加的 XML。我没有在控制台中收到错误,但也没有突出显示。
javascript:
<script type="text/javascript" src="js/syntaxhighlighter_3.0.83/scripts/shCore.js"></script>
<script type="text/javascript" src="js/syntaxhighlighter_3.0.83/scripts/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="js/syntaxhighlighter_3.0.83/styles/shCoreDefault.css"
<script>
function generateXML()
{
var result="<test>WHATEVA</test>";
alert(result);
var regex1 = new RegExp('<', 'g');
var regex2 = new RegExp('>', 'g');
result = "<pre class='brush: xml'>" + result.replace(regex1,'<').replace(regex2,'>')+"</pre>";
document.getElementById("generatedXML").innerHTML = result;
}
</script>
HTML
<input id="addOUTPUTButton" type="button" value="Generate XML" onclick="generateXML()"/>
<input id="test" type="button" value="Test" onclick="SyntaxHighlighter.all();"/>
<div id="generatedXML">
</div>