W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] clarification for data-uris in window.open and SOP

From: Andreas Göbel <andreas.goebel@typeofnan.com>
Date: Tue, 8 Feb 2011 22:38:52 +0100
Message-ID: <536C5055-1ACB-4176-9B2B-217A6221CCD0@typeofnan.com>
Recently I needed to have some base64 encoded images to show in a new window. My first attempt was, to just pass the data:image/png;base64,<data> string as first argument from window.open().

This works in all browsers that support data-uris, but it is terribly slowing down the browser when passing in images with a "big" filesize. My idea was to do something like this:

var largeprev = window.open('data:text/html;charset=utf-8,' + escape('<div/>'), 'large'),
    that      = this;

    largeprev.addEventListener('DOMContentLoaded', function(e) {
        largeprev.alert('loaded');
        largeprev.document.querySelectorAll('div')[0].appendChild(that);
    }, false);
this works great in Firefox (3.6.x), but Chrome and Safari treat the returned DOMWindow object like it represents a foreign domain. Technically, it is not the same domain obviously since I'm passing in a data:text/html data-uri, but I would be shocked if the Same Origin Policy would deny an attempt like this ?

What should be the correct behavior for this ?

--Andy
Received on Tuesday, 8 February 2011 13:38:52 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:30 UTC