Created
March 22, 2012 05:21
-
-
Save hatelove/2156312 to your computer and use it in GitHub Desktop.
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
function doIframe(){ | |
o = document.getElementsByTagName('iframe'); | |
for(i=0;i<o.length;i++){ | |
if (/\bautoHeight\b/.test(o[i].className)){ | |
setHeight(o[i]); | |
addEvent(o[i],'load', doIframe); | |
} | |
} | |
} | |
function setHeight(e){ | |
if(e.contentDocument){ | |
e.height = e.contentDocument.body.offsetHeight + 35; | |
} else { | |
e.height = e.contentWindow.document.body.scrollHeight; | |
} | |
} | |
function addEvent(obj, evType, fn){ | |
if(obj.addEventListener) | |
{ | |
obj.addEventListener(evType, fn,false); | |
return true; | |
} else if (obj.attachEvent){ | |
var r = obj.attachEvent("on"+evType, fn); | |
return r; | |
} else { | |
return false; | |
} | |
} | |
if (document.getElementById && document.createTextNode){ | |
addEvent(window,'load', doIframe); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment