Skip to content

Instantly share code, notes, and snippets.

@pingyen
Last active August 29, 2015 21:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pingyen/47545 to your computer and use it in GitHub Desktop.
Save pingyen/47545 to your computer and use it in GitHub Desktop.
Put JS into Iframe 3
<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>
@pingyen
Copy link
Author

pingyen commented May 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment