Results 1 to 3 of 3

Thread: simple code works on ie but not in ff

  1. #1
    Join Date
    Nov 2008
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default simple code works on ie but not in ff

    hello, I have this code to resize an iframe based on its content, but it works only with ie and not ff, any help?
    Code:
    <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

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    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

  3. #3
    Join Date
    Dec 2008
    Location
    Nigeria
    Posts
    95
    Thanks
    3
    Thanked 8 Times in 8 Posts

    Default

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •