1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-04-16 16:51:53 +02:00
This commit is contained in:
Kushagra Gour 2018-02-08 03:31:34 +05:30
parent 16acb03593
commit 153f0d8c7a
4 changed files with 24 additions and 2 deletions

13
app/detached-window.js Normal file
View File

@ -0,0 +1,13 @@
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;
}
});

9
app/preview.html Normal file
View File

@ -0,0 +1,9 @@
<link rel="stylesheet" href="style.css">
<body>
<iframe src="about://blank" frameborder="0" id="demo-frame" allowfullscreen></iframe>
<script src="detached-window.js"></script>
</body>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long