Staring whole code in a variable -- Javascript
<p>I want to store javascript code in a javascript variable.
To explain clearly, please consider example:</p>

<pre><code>&lt;html&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;
&lt;!--

    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
//--&gt;
&lt;/script&gt;

&lt;a onclick="toggle_visibility('1');toggle_visibility('2');"&gt;Click here to toggle visibility of element &lt;/a&gt;
&lt;div id="1"&gt;This is 1&lt;/div&gt;
&lt;div id="2"&gt;This is 2&lt;/div&gt;

&lt;script type="text/javascript"&gt;
//document.getElementById('2').style.display='none';
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Now suppose all this code is in a variable as a string or something. (i want to do this because i am exporting file to another html page where the code should get copied.) 
I used all variables such as 
using \ before ' and so on. referring to <a href="http://www.w3schools.com/js/js_special_characters.asp" rel="nofollow">http://www.w3schools.com/js/js_special_characters.asp</a></p>
