Jump to content

localidiot

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by localidiot

  1. Remove window.parent. If this code is in the <iframe> tag itself, the window is still the same window, unless you have a frame within a frame:
    onload="sizeFrame('myFrame');"

    I still get an error about an object required. Any thoughts?I tried to run a debugger and got this in returne:uncaught exception TypeError: Cannot read property 'contentDocument' of null
  2. Brilliant, exactly what i was looking for. Thank you very much.
    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.
    <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.

  3. 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?

×
×
  • Create New...