-
Posts
4 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by localidiot
-
-
I am trying to extend this javascript with the ability to detect the element ID that is passed to the function using the onload function of the Iframe.Brilliant, exactly what i was looking for. Thank you very much.<script type="text/javascript"><!--//function sizeFrame(frameId) {var F = document.getElementById(frameId);if(F.contentDocument) {F.height = F.contentDocument.documentElement.scrollHeight+30; //FF 3.0.11, Opera 9.63, and Chrome} else {F.height = F.contentWindow.document.body.scrollHeight+30; //IE6, IE7 and Chrome}}window.onload=sizeFrame; //--></script>
<iframe width="100%" id="myFrame" src="testincludegallery.php?id=1" scrolling="no" frameborder="0" onload="window.parent.sizeFrame('myFrame');">
As of now I am hard coding the ID of the element. However I am stuck at an IE error that says object expected. It still appears to work in all browsers, however in ie i get the object error.
-
Brilliant, exactly what i was looking for. Thank you very much.
-
function SetCwinHeight(){ var cwin=document.getElementById("cwin"); if (document.getElementById){ if (cwin) { if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight) cwin.height = cwin.contentDocument.body.offsetHeight; else if(cwin.Document && cwin.Document.body.scrollHeight) cwin.height = cwin.Document.body.scrollHeight; } }}
<iframe src="somepagegoes.here.php?id=44" align="center" width="100%" id="cwin" name="cwin" onload="java script:SetCwinHeight()" frameborder="0" scrolling="no"></iframe>
This code works in IE, however it fails in all other browsers. I tried to find if any of the source is specific to IE and I failed that test. Is there anyway of turning this into browser friendly code?
Iframe Auto Resize Height
in JavaScript
Posted · Edited by water boy