- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Thu, 19 Apr 2012 19:33:51 -0400
- To: public-web-perf@w3.org
On 4/19/12 1:44 PM, Sreeram Ramachandran wrote:
>> Well, one benefit is that UAs won't claim navigated-away-from documents as
>> "visible", no? From a developer point of view, that's just weird.
>
> Is it actually possible to observe, interact or in any way script a
> document that has been navigated-away-from?
It's possible to observe it from script and to script it, yes. Script
can interact with it, too.
> If so, could you show an example of how to do it?
Sure. Here you are:
<!doctype html>
<script>
var doc;
window.onload = function() {
var frame = document.querySelector("#f");
doc = frame.contentWindow.document;
doc.documentElement.textContent = "First"
frame.onload = doIt;
frame.src = 'data:text/html,Next';
}
function doIt() {
alert(doc);
alert(doc.documentURI);
alert(doc.documentElement.textContent);
}
</script>
<iframe id="f" src="about:blank"></iframe>
Replace about:blank with a same-origin URI of your choice (can't use
data: there in WEbKit, of course). But in any case, both WebKit and
Gecko alert "about:blank" for the URI and "First" for the textContent.
Opera is doing something weird with reusing the document here that I
hope they don't do when about:blank and data are not involved.
> When I tried, I found that the document and
> window references I had in hand live-updated to the current document,
Well the window just shows whatever is currently loaded in the window.
The document reference should not "live-update".
-Boris
Received on Thursday, 19 April 2012 23:34:24 UTC