autoresize iframe inside table cell not working
Posted on 2013-10-07
Anway, to resize the IFRAME, you have to call an autoresize function as an onLoad defined in the IFRME, such as:
<iframe src="<?php echo $URL; ?>/iframe_content_page.phtml"
width="100%" height="200px" id="iframe1"
marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>
The problem is, no page is loaded into the IFRAME unless I remove the call to the autoresize function.
I have tested the use of the autoresize function using an IFRAME in a page that has no DIV tabs, etc. It works fine.
I know that the autoresize function is being called, though, because, if I add an alert() inside it, the alert displays fine.
The information about the scrollHeight and scrollWidth to resize the IFRAME, however, is not being set. I can confirm this by passing one of these parameters to alert() from inside the autoresize function. They are always zero. I have confirmed that the id for the IFRAME is being passed to the autoresize function, as alert() will report this, from inside the function.
The web page being loaded into the IFRAME is not a static HTML page. It is generated using a PHP function and an HTML template page. This is not the issue, however. I know because, if I display this constructed page in a separate browser, then do a View Source, and then copy this source file to a web page having same name as the IFRAME src file, the page still doesn't load if the call to the autoResize() function is present. So, making the src page a static HTML page doesn't resolve the issue.
No idea why the scrollHeight and scrollWidth information is not available to the autoResize function. I have even tried setting height and width inside the autoresize function (hard code), and this will work..
The height and width information is obtained as follows:
However, as I said, the height and width are not being set, even if I replace "id" in the call to getElementById() with 'iframe1' (including the single quotes), the id of the IFRAME.
It's as if getElementById() can't find the IFRAME.