Skip to content

Instantly share code, notes, and snippets.

@alonronin
Created January 21, 2020 02:37
Show Gist options
  • Save alonronin/27abec3d9f337512bfebe70970077240 to your computer and use it in GitHub Desktop.
Save alonronin/27abec3d9f337512bfebe70970077240 to your computer and use it in GitHub Desktop.
JS Bin friendly iframe // source https://jsbin.com/setudej/2
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="friendly iframe">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
html {
height: 100vh;
display: flex;
}
body {
flex: 1;
display: flex;
}
iframe {
flex: 1;
border: 1px solid black;
}
</style>
</head>
<body>
<iframe>
<!DOCTYPE html>
<html>
<body>
<h1>Cool</h1>
</body>
<script>
log('test');
</script>
</html>
</iframe>
<script id="jsbin-javascript">
window.addEventListener('DOMContentLoaded', e => {
const iframe = document.querySelector('iframe');
const html = iframe.innerHTML;
iframe.innerHTML = '';
iframe.contentWindow.log = console.log;
iframe.contentDocument.open().write(html);
iframe.contentDocument.close();
})
</script>
<script id="jsbin-source-css" type="text/css">html {
height: 100vh;
display: flex;
}
body {
flex: 1;
display: flex;
}
iframe {
flex: 1;
border: 1px solid black;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">
window.addEventListener('DOMContentLoaded', e => {
const iframe = document.querySelector('iframe');
const html = iframe.innerHTML;
iframe.innerHTML = '';
iframe.contentWindow.log = console.log;
iframe.contentDocument.open().write(html);
iframe.contentDocument.close();
})
</script></body>
</html>
html {
height: 100vh;
display: flex;
}
body {
flex: 1;
display: flex;
}
iframe {
flex: 1;
border: 1px solid black;
}
window.addEventListener('DOMContentLoaded', e => {
const iframe = document.querySelector('iframe');
const html = iframe.innerHTML;
iframe.innerHTML = '';
iframe.contentWindow.log = console.log;
iframe.contentDocument.open().write(html);
iframe.contentDocument.close();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment