Created
January 21, 2020 02:37
-
-
Save alonronin/27abec3d9f337512bfebe70970077240 to your computer and use it in GitHub Desktop.
JS Bin friendly iframe // source https://jsbin.com/setudej/2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
height: 100vh; | |
display: flex; | |
} | |
body { | |
flex: 1; | |
display: flex; | |
} | |
iframe { | |
flex: 1; | |
border: 1px solid black; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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