PDA

View Full Version : simple code works on ie but not in ff



bojomojo
12-07-2008, 04:30 PM
hello, I have this code to resize an iframe based on its content, but it works only with ie and not ff, any help?

<script type="text/javascript" language="javascript">
function resizeIframe(iframeID) {
if(self==parent) return false; /* Checks that page is in iframe. */
else if(document.getElementById&&document.all) /* Sniffs for IE5+.*/

var FramePageHeight = framePage.scrollHeight + 40; /* framePage is the ID of the framed page's BODY tag. The added 10 pixels prevent an unnecessary scrollbar. */

parent.document.getElementById(iframeID).style.height=FramePageHeight; /* "iframeID" is the ID of the inline frame in the parent page. */
}
</script>

then its loaded onload in thebody tag

Snookerman
12-07-2008, 04:35 PM
You guys might also wanna take a look at this thread where the code comes from for further info:

http://www.dynamicdrive.com/forums/showthread.php?t=39499 (http://www.dynamicdrive.com/forums/showthread.php?t=39499)

diltony
12-16-2008, 11:01 PM
I have not tested out the code, but i no that if the domains are different, there is no way u will be calling javascript accross like the iframe saying that "parent.resize", the parent window wont listen 'cos the domain is not a child!!
However if u call your resize...from within the main window, u can get it to resize the iframe even if it is from another domain, u can fetch properties within the iframe but cannot manipulate if it is crossdomain, but resizing an iframe will not infringe on any rights....