1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-05-08 03:25:27 +02:00
php-web-maker/src/detached-window.js
Arnab Sen d13e7981e0
Replace preview with index in the check
The iframe where the output is displayed in case of Files Mode has
the url http(s)://<domain>/index.html and not preview.html.
2022-03-12 12:26:23 +05:30

21 lines
599 B
JavaScript

window.addEventListener('message', e => {
// Recieving from app window
if (e.data && e.data.contents && e.data.contents.match(/<html/)) {
const frame = document.querySelector('iframe');
frame.src = frame.src;
setTimeout(() => {
frame.contentDocument.open();
frame.contentDocument.write(e.data.contents);
frame.contentDocument.close();
}, 10);
}
if (e.data && e.data.url && e.data.url.match(/index\.html/)) {
document.querySelector('iframe').src = e.data.url;
}
// Recieving from preview iframe
if (e.data && e.data.logs) {
window.opener.postMessage(e.data, '*');
}
});