Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>if I take the guts of the render() function out (i.e., just put them after load() in main.js), this works fine.</p> </blockquote> <p>Doesn't for me in IE8. If I lose the AJAX call completely and just call <code>render()</code> in main.js, I get the same result. In fact even if I replace the whole of main.js with just:</p> <pre><code>document.write('hello!'); </code></pre> <p>with or without opening the document, the hello never appears!</p> <p>If I put any timeout (even 0) on the call to <code>render</code> in main.js, it works. The timeout on the parent document, on the other hand, doesn't seem to be doing anything.</p> <p>This extreme weirdness is caused by jQuery using a temporarily-inserted <code>&lt;script&gt;</code> tag to execute the code returned by in jsonp.js. If you simply call <code>eval</code> on the return value instead of having jQuery execute it, it works fine.</p> <p>A related problem I found narrowing down the hello example is demonstrated by index.html:</p> <pre><code>&lt;body&gt; &lt;iframe name="foo"&gt;&lt;/iframe&gt; &lt;script&gt; var idoc= frames['foo'].document; idoc.open(); idoc.write('&lt;body&gt;&lt;script src="main.js"&gt;&lt;\/script&gt;'); idoc.close(); &lt;/script&gt; </code></pre> <p>with main.js containing:</p> <pre><code>document.write('foo'); </code></pre> <p>There is no foo written. (An inline script, on the other hand, was fine.)</p> <p>If the <code>idoc.close</code> was omitted, it worked. If an additional <code>idoc.write('bar')</code> was added, the <code>bar</code> was written before <code>foo</code> in IE only. If I added both <code>bar</code> and the <code>close</code> call, IE crashed.</p> <p>So to summarise, there are <strong>deep problems</strong> using <code>document.write</code> from inside a document that was itself written by <code>document.write</code>! Try to avoid it if at all possible. <code>document.open</code> can be a useful way to populate an iframe from a parent document, but you shouldn't really be needing it inside the child document, where you can use DOM methods on yourself.</p>
 

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