Note that there are some explanatory texts on larger screens.

plurals
  1. PO<script> inside javascript code document.write()
    primarykey
    data
    text
    <p>I got a portion of javascript code embedded in HTML (generated on the server side) that looks like this:</p> <pre><code>function winWriteMail2(){ var win = open('','wininfo', 'width=400,height=300,scrollbars=yes,resizable=yes'); win.document.open(); win.document.write('&lt;HTML&gt;&lt;HEAD&gt;&lt;META http-equiv="Content-type" content="text/html; charset=iso-8859-2"&gt;&lt;LINK rel="stylesheet" type="text/css" href="/css/main.css"&gt;'); win.document.write('&lt;scr' + 'ipt language="javascript" type="text/javascript" src="/js/JSFILE.js"&gt;&lt;/scr' + 'ipt&gt;'); win.document.write('&lt;/HEAD&gt;&lt;BODY BGCOLOR="#f7f3e7"&gt;'); &lt;!-- window content goes here --&gt; win.document.write('&lt;/BODY&gt;&lt;/HTML&gt;'); win.document.close(); } </code></pre> <p>This code gets executed on click of a element. </p> <p>The problematic part for me is the inclusion of javascript file - it works ok in Firefox and Chrome, but IE (7 and 8, as I tested) behaves strange. With the line containing <code>JSFILE</code> there, the window on click gets opened, but is empty, CPU is 100% busy and only way is to kill IE. </p> <p>Anyone can help with handling this problem? Maybe I should use some other way to insert the javascript files in there? </p> <p>I tried, instead of <code>win.document.write()</code>, the DOM-manipulation method, putting this part of code after <code>win.document.close()</code>:</p> <pre><code>h = win.document.getElementsByName('head')[0]; js = document.createElement('script'); js.src = '/js/JSFILE.js'; h.appendChild(js); </code></pre> <p>but then the code isn't loaded, even in Firefox (and inspecting with firebug doesn't show it even can see it). </p> <hr> <p>After some checks, I found out that the problem is caused by <code>&lt;script&gt;</code> elements with a <code>src=</code> attribute defined. If I add an inline script, like:</p> <pre><code>&lt;script type='text/javascript'&gt;alert('foo')&lt;/script&gt; </code></pre> <p>within my <code>document.write()</code>, the window opens, the alert box shows up and everything's all right. </p> <p>But using a </p> <pre><code>&lt;script type='text/javascript' src='/js/foo.js'&gt;&lt;/script&gt; </code></pre> <p>IE stalls when opening the new window, keeps using 100% of CPU.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload