Last active
August 29, 2015 21:25
-
-
Save pingyen/47523 to your computer and use it in GitHub Desktop.
Put JS into Iframe
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
<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