Skip to content
Snippets Groups Projects
Commit c7632c7d authored by lehtint6's avatar lehtint6
Browse files

Fix iframe messaging and resize automatically

parent e684cf9a
Branches
No related tags found
No related merge requests found
......@@ -102,15 +102,20 @@ ACOSWebdev.prototype.editorExecute = function (cb) {
+ ' display.err(error.message);\n'
+ ' throw error;\n'
+ '}\n'
+ 'window.postMessage({state: "done"}, "*");\n'
+ 'window.parent.postMessage({state: "done"}, "*");\n'
+ '</script>\n'
+ (this.config.postExecuteHtml || '')
+ (this.config.postExecuteScript ? ('<script src="' + this.config.postExecuteScript + '"></script>\n') : '')
+ '</body>\n</html>\n';
window.addEventListener('message', function (event) {
function onDone(event) {
if (event.data.state == 'done') {
window.removeEventListener('message', onDone);
var h = $iframe.get(0).contentWindow.document.body.scrollHeight;
$iframe.css('height', h + 10 + 'px');
cb();
}
});
}
window.addEventListener('message', onDone);
$iframe.attr('src', 'javascript:window["contents"]');
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment