1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-22 14:31:13 +02:00

fix detached window updation in webapp

This commit is contained in:
Kushagra Gour
2018-02-08 03:24:47 +05:30
parent 6b018310f0
commit 16acb03593
3 changed files with 29 additions and 10 deletions

View File

@@ -1,3 +1,13 @@
window.addEventListener('message', e => {
document.querySelector('iframe').src = e.data;
if (e.data && e.data.contents) {
const frame = document.querySelector('iframe');
frame.src = frame.src;
setTimeout(() => {
frame.contentDocument.open();
frame.contentDocument.write(e.data.contents);
frame.contentDocument.close();
}, 10);
} else {
document.querySelector('iframe').src = e.data;
}
});