Skip to content

Instantly share code, notes, and snippets.

@pingyen
Last active August 29, 2015 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingyen/47523 to your computer and use it in GitHub Desktop.
Save pingyen/47523 to your computer and use it in GitHub Desktop.
Put JS into Iframe
<iframe id="_if1" scrolling="no" style="width : 100%" ></iframe>
<script>
(function() {
var oIf = document.getElementById('_if1'),
win = oIf.contentWindow,
doc = win.document;
doc.write('<html><head></head><body><script src="http://postpet.jp/webmail/blog/clock_v1_moco.js" ></sc' + 'ript><body></html>');
if(doc.all) {
var scArr = doc.getElementsByTagName('script'),
oSc = scArr[scArr.length - 1];
_check();
return;
function _check() {
var rs = oSc.readyState;
if(rs == 'loaded' || rs == 'complete') {
doc.close();
_height();
return;
}
setTimeout(_check, 100);
}
}
win.onload = _height;
doc.write('<script> document.close(); </sc' + 'ript>');
function _height() {
oIf.style.height = doc.body.scrollHeight + 'px';
}
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment