Results 1 to 3 of 3

Thread: Problem with iframe dynamic height auto adjusting

  1. #1
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with iframe dynamic height auto adjusting

    I use the following code to achieve dynamic iframe height:

    In the <head>:
    Code:
    <script src="jquery-1.10.2.min.js"></script>
    <script language="javascript" type="text/javascript">
      function resizeIframe(obj) {
        obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
    	var iframeDoc = $('iframe[name="dservers"]').contents().get(0);
    $('iframe[name="dservers"]').load(function(){
        docHeight = $(iframeDoc).height();
        $('iframe[name="dservers"]').height( docHeight );
    });
      }
    </script>
    In the <body>
    Code:
    <iframe name="dservers" src="dual_core.html" width="100%" frameborder="0" scrolling="no" onload='javascript:resizeIframe(this);' /></iframe>
    This code works fine and it dynamically adjust the height.
    The Problem here is the Firefox. It do adjust the height of the iframe dynamically but when the content height in the iframe decrease, the iframe doesn't decrease with it. So it is auto adjusting the height if it is getting taller only and not shrinks if the height decreased, causing big unwanted white space. Chrome and IE are working fine at the moment.

    Here is my page. Please take a look on it and let me know if anyone has any solution for this problem. Any help would be appreciated, Thank you guys!

    Some Screenshots:

    Click image for larger version. 

Name:	ps_blur1_chrome.jpg 
Views:	721 
Size:	15.9 KB 
ID:	5299Click image for larger version. 

Name:	ps_blur2_chrome.jpg 
Views:	607 
Size:	14.0 KB 
ID:	5300

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

  3. #3
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Problem Solved, Thanks to molendijk

    Quote Originally Posted by molendijk View Post
    This may be helpful.
    That solved the problem! Thank you very much for your help. I appreciate it.

Similar Threads

  1. Problem with auto height Iframe SSI scrolling when expand accordion
    By xsyam in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 08-01-2013, 02:34 PM
  2. Iframe SSI script II not working for IE (auto height of IFrame)
    By mubimasti in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 11-14-2012, 09:30 AM
  3. Replies: 6
    Last Post: 03-11-2008, 01:18 PM
  4. Replies: 0
    Last Post: 08-06-2007, 06:12 AM

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
  •