Hi i am trying to insert the great syntaxhighlighter into an asp .net page but every time it has a error saying ‘dp is undefined’.
I think that it gets to the calling part before it downloads the scripts, how can i make sure the files are loaded before continuing?
Thanks
Doron
Edit: this is the code I use in my aspx file, it works fine as regular HTML but when i try and use in a aspx file it says ‘dp is undefined’
<link type="text/css" rel="stylesheet" href="App_Data/Styles/SyntaxHighlighter.css"></link>
<script type="text/javascript" src="App_Data/Scripts/shCore.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushCss.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushJava.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushPython.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushRuby.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushSql.js"></script>
<script type="text/javascript" src="App_Data/Scripts/shBrushXml.js"></script>
<script type="text/javascript">
window.onload = function() {
dp.SyntaxHighlighter.ClipboardSwf = 'http://aaron-mueller.de/vendor/dp_syntax_highlighter/Scripts/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
}
</script>
Actually, if putting scripts in right order, everything should work fine:
But it can happen, that the highlighter injects the <script> tags himselves, and in this case Jakub’s solution should help: perform everything on document load.
Use either
event or (if using jQuery)