www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 05-31-2007, 05:40 PM
    jadeite100 jadeite100 is offline
    Registered User
     
    Join Date: May 2007
    Posts: 11
    What is the difference between height, scrollHeight and style.height

    Hi:

    I have a IFrame called "dataFrame". Does anybody know the difference between

    document.getElementById('dataFrame').height

    and

    document.getElementById('dataFrame').Document.body.scrollHeight;

    and

    document.getElementById('dataFrame').style.height


    Quote:
    function shrinkIFrame() {

    var theFrame=document.getElementById('dataFrame');
    var header,headerHeight,footer,navPrimaryMenu,navPrimaryMenuHeight,mainMenu2,iFrameHeight,mainMenu2Heigh t,wholeWindowHeight;
    var totalHeight,differenceHeight;

    if(theFrame){

    theFrame.style.display="block"
    if(theFrame.Document && theFrame.Document.body.scrollHeight)
    {


    header=parent.document.getElementById('Header2');
    navPrimaryMenu=parent.document.getElementById('navPrimaryMenu');
    mainMenu2=parent.document.getElementById('mainMenu2');

    headerHeight = header.offsetParent.offsetHeight;
    navPrimaryMenuHeight=navPrimaryMenu.scrollHeight;
    mainMenu2Height=mainMenu2.scrollHeight;
    wholeWindowHeight=document.body.offsetHeight;
    iFrameHeight =theFrame.Document.body.scrollHeight;

    totalHeight =headerHeight+mainMenu2Height+navPrimaryMenuHeight;

    differenceHeight = wholeWindowHeight - totalHeight;



    //alert("differenceHeight: " + differenceHeight);

    if (iFrameHeight > differenceHeight)
    {
    // 92 represent the row header, one row and the scrollbar
    //alert("iFrameHeight > differenceHeight");
    if (differenceHeight > 92)
    {

    theFrame.style.height=differenceHeight+ 'px';
    }
    else
    {
    alert("theFrame.height:"+theFrame.height+"theFrame.Document.body.scrollHeight:"+theFrame.Document.bo dy.scrollHeight);
    alert("differenceHeight:"+differenceHeight+"theFrame.style.height:"+theFrame.style.height);

    theFrame.height=theFrame.Document.body.scrollHeight;

    }

    }
    else
    {

    theFrame.style.height = differenceHeight +'px';
    }


    }
    if(theFrame.attachEvent){

    theFrame.detachEvent("onload", readjustIframe)
    theFrame.attachEvent("onload", readjustIframe)
    }
    }

    }



    Yours,

    Frustrated
    Reply With Quote
      #2  
    Old 05-31-2007, 05:53 PM
    toicontien's Avatar
    toicontien toicontien is offline
    er, I mean toicantien
     
    Join Date: Feb 2003
    Location: Chicago Area, IL
    Posts: 5,469
    In your case, .height refers to the value in the IFRAME's height HTML attribute. The .style.height refers to a CSS property set in the style attribute of the IFRAME tag. The .scrollHeight is the height in pixels of the scrollable area of the IFRAME. If something is taller than the scrollHeight, then scrollbars will appear on the IFRAME.
    Reply With Quote
      #3  
    Old 06-01-2007, 10:43 AM
    jadeite100 jadeite100 is offline
    Registered User
     
    Join Date: May 2007
    Posts: 11
    What is IFrame.offsetHeight

    Hi:

    Can you please tell me what is the
    parent.document.getElementById('dataFrame').offsetHeight


    Thanks.
    Reply With Quote
      #4  
    Old 06-01-2007, 11:48 AM
    toicontien's Avatar
    toicontien toicontien is offline
    er, I mean toicantien
     
    Join Date: Feb 2003
    Location: Chicago Area, IL
    Posts: 5,469
    In JavaScript, parent is a key word that allows you access to the current frame's, parent frame's window object. So:

    window: The window object of the current frame

    parent: The window object of this window's parent frame. It can also be written as window.parent.

    That snippet of code says "Get the HTML tag whose Id is 'dataFrame' in the parent frame's document." And the ".offsetHeight" part is a DOM node property that is the height of an element, including any margins, padding and borders.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:39 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.