Re: [whatwg] Avoiding synchronous iframe load

Note that loads can never be fully async, you'd break tons of content.
Navigating to about:blank is synchronous.

frame = document.createElement('iframe');
document.body.appendChild(frame);
frame.contentDocument; // synchronously available

Also javascript: URLs are not async in Firefox:

frame = document.createElement('iframe');
frame.src = 'javascript:alert(1);'
document.body.appendChild(frame);
alert(2);

This alerts 1 and then 2.

Presumably all this behavior is required by spec. If it wasn't then we
should fix the spec since not having that behavior would break nearly ever
major web app.


On Tue, Oct 15, 2013 at 7:02 PM, Ryosuke Niwa <rniwa@apple.com> wrote:

> Hi,
>
> I'm trying to make page loads on iframe always asynchronous in WebKit.
>  However, the current specification appears to indicate that the navigation
> happens synchronously.
>
> Namely, in the following example, the first alert should be "true" as far
> as I read the specification.
>
> <script> var a = false; </script>
> <iframe src="javascript:a=true" onload="a = true"></iframe>
> <script> alert(a); /* or even setTimeout(function(){alert(a);},0); */
> setTimeout(function(){alert(a);},10) </script>
>
> On the other hand, Firefox and Internet Explorer do not synchronously load
> iframes, and the first alert in the example above yields "false" although
> it yields "true" on WebKit and Blink.
>
> Am I reading the specification wrong/missing something?  If not, could you
> amend the specification to make page loads on an iframe always asynchronous?
>
> - R. Niwa
>
>

Received on Thursday, 17 October 2013 22:15:38 UTC