mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
function FrameContainer(container, sameOrigin, options) {
|
|
this.image = null;
|
|
this.src = container;
|
|
var self = this;
|
|
var bounds = getBounds(container);
|
|
this.promise = (!sameOrigin ? this.proxyLoad(options.proxy, bounds, options) : new Promise(function(resolve) {
|
|
if (container.contentWindow.document.URL === "about:blank" || container.contentWindow.document.documentElement == null) {
|
|
container.contentWindow.onload = container.onload = function() {
|
|
resolve(container);
|
|
};
|
|
} else {
|
|
resolve(container);
|
|
}
|
|
})).then(function(container) {
|
|
return html2canvas(container.contentWindow.document.documentElement, {type: 'view', proxy: options.proxy, javascriptEnabled: options.javascriptEnabled, removeContainer: options.removeContainer});
|
|
}).then(function(canvas) {
|
|
return self.image = canvas;
|
|
});
|
|
}
|
|
|
|
FrameContainer.prototype.proxyLoad = function(proxy, bounds, options) {
|
|
var container = this.src;
|
|
return loadUrlDocument(container.src, proxy, container.ownerDocument, bounds.width, bounds.height, options);
|
|
};
|