javascript – Syntaxhighlighter autoloader
作者:互联网
我从http://alexgorbatchev.com/SyntaxHighlighter/获得了SyntaxHighlighter
我不能让自动加载器工作.我究竟做错了什么?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="styles/shCoreDefault.css" rel="stylesheet" type="text/css" />
<script src="scripts/shCore.js" type="text/javascript"></script>
<script src="scripts/shAutoloader.js" type="text/javascript"></script>
<script type="text/javascript">
SyntaxHighlighter.autoloader('js scripts/shBrushJScript.js');
SyntaxHighlighter.all();
</script>
</head>
<body>
<pre class="brush: js">
function foo()
{
}
</pre>
</body>
</html>
我确保我的网址/脚本路径是正确的.
这有效,但我真的很想让自动加载器工作.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="styles/shCoreDefault.css" rel="stylesheet" type="text/css" />
<script src="scripts/shCore.js" type="text/javascript"></script>
<script src="scripts/shBrushJScript.js" type="text/javascript"></script>
<script type="text/javascript">
SyntaxHighlighter.all();
</script>
</head>
<body>
<pre class="brush: js">
function foo()
{
}
</pre>
</body>
</html>
解决方法:
要使“SyntaxHighlighter.autoloader”工作,您应该移动“pre”部分下的行或将其放入文档就绪的回调中.
“自动加载器”方法检查当前加载的“预”部分并请求相应的画笔.因此,如果它在加载body元素之前执行,则不会加载画笔.
标签:javascript,syntax-highlighting 来源: https://codeday.me/bug/20190715/1471536.html