Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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:



    Attached Thumbnails Attached Thumbnails Problem with iframe dynamic height auto adjusting-ps_blur1_chrome.jpg   Problem with iframe dynamic height auto adjusting-ps_blur2_chrome.jpg  

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,096
    Thanks
    23
    Thanked 594 Times in 593 Posts
    Your link does not work - I was forbidden and got
    You don't have permission to access /dedicated-servers/ on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    From the blurred image you posted; stop using iframes! What you have can and should be done in normal HTML using DIVs and min-height.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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