# Literally insert javascript code into DOM

**URL:** <https://forum.kirupa.com/t/literally-insert-javascript-code-into-dom/301346>\
**Category:** web dev\
**Created:** [December 8, 2009, 2:13am UTC](https://forum.kirupa.com/t/literally-insert-javascript-code-into-dom/301346 "2009-12-08T02:13:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeoDreamer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NeoDreamer](https://forum.kirupa.com/u/NeoDreamer)\
**Post date:** [December 8, 2009, 2:13am UTC](https://forum.kirupa.com/t/literally-insert-javascript-code-into-dom/301346/1 "2009-12-08T02:13:59Z")

</div>

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.

```php

// 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>

```

```php

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. 🙂
