How do I insert code literally in the DOM without it being evaluated? I’m generating some dynamic code that I want people to be able to copy and paste.
// This didn't evaluate the CSS, but did evaluate the JS
// The JS was replaced with a blank line
<textarea id="foo"></textarea>
// This evaluated both CSS and JS. No text was visible.
<pre id="foo"></pre>
document.getElementById('foo').innerHTML =
'<link type="text/css" rel="stylesheet" href="file.css" />
' +
'<script type="text/javascript" src="file.js">';
And if anyone has a Prototype solution, then that would be great.