1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-02-23 14:44:53 +01:00
php-web-maker/app/detached-window.js
Kushagra Gour 153f0d8c7a build
2018-02-08 03:31:34 +05:30

14 lines
364 B
JavaScript

window.addEventListener('message', e => {
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;
}
});