Last active
August 29, 2015 21:25
-
-
Save pingyen/47545 to your computer and use it in GitHub Desktop.
Put JS into Iframe 3
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="_if3" scrolling="no" style="width : 100%" ></iframe> | |
<script> | |
(function() { | |
var oIf = document.getElementById('_if3'), | |
win = oIf.contentWindow, | |
doc = oIf.contentWindow.document; | |
doc.write('<html><head></head><body><script> google_ad_client = "pub-1821434700708607"; google_ad_slot = "8156194155"; google_ad_width = 200; google_ad_height = 200; </sc' + 'ript><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></sc' + 'ript>'); | |
if(doc.all) { | |
var ifArr = doc.getElementsByTagName('iframe'); | |
_check(); | |
return; | |
function _check() { | |
if(ifArr.length) { | |
doc.close(); | |
_height(); | |
return; | |
} | |
setTimeout(_check, 100); | |
} | |
} | |
win.onload = _height; | |
doc.write('<script> document.close(); </sc' + 'ript><body></html>'); | |
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
http://blog.xuite.net/vexed/tech/21851083