How to open a new window with generated javascript code?
<p>I am trying to open a new window and write some elements and javascript tag.</p>

<p>The code looks like,</p>

<pre><code>var OpenWindow = window.open("ImagePreview.html", "mywindow","height=768,width=1024");
OpenWindow.document.write("&lt;style type='text/css'&gt;.normal{zoom:20%; -moz-transform:scale(0.2); cursor:pointer;}.notZoomed{zoom:20%; -moz-transform:scale(0.2); cursor:pointer;}.zoomed{zoom:100%; -moz-transform:scale(1); cursor:pointer;}&lt;/style&gt;");
OpenWindow.document.write("&lt;script type='text/javascript'&gt;$(function(){$('#imageFullView').data('zoomed', false);$('#imageFullView').click(function(){$('#imageFullView').removeClass('normal');if($('#imageFullView').data('zoomed')){$('#imageFullView').removeClass('zoomed');$('#imageFullView').addClass('notZoomed');$('#imageFullView').data('zoomed', false);}else{$('#imageFullView').removeClass('notZoomed');$('#imageFullView').addClass('zoomed');$('#imageFullView').data('zoomed', true);}})");
OpenWindow.document.write("&lt;img id='imageFullView' class='normal' src='" + data.previewImage + "' alt='img'/&gt;");
OpenWindow.document.write("&lt;br&gt;");
OpenWindow.document.write("&lt;center&gt;&lt;a href='javascript:self.close()' target='_self'&gt;Close&lt;/a&gt;&lt;/center&gt;");
</code></pre>

<p>But the code breaks while trying to write javascript tag with code.
If i remove that line code executes without breaking.</p>

<p>Is it not the right way to add javascript code to a page <code>window.open()</code>?</p>

<p>How to do it using jquery?</p>

<p>Thanks!</p>
