2 Replies Latest reply on Sep 26, 2012 12:40 PM by sgfone

    Flex 4.6 - how to obtain the true height of a loaded HTML page

    sgfone Level 1

      I am trying to obtain the (true) height of a loaded HTML page.  It is being loaded by setting the location property of the mx:HTML id="browserInsideFlex" loader.  I have added a listeners for the following:

       

      browserInsideFlex.addEventListener(Event.HTML_RENDER, onHTMLrender);

      browserInsideFlex.addEventListener(Event.HTML_DOM_INITIALIZE,onHTMLDOMInit);

      browserInsideFlex.addEventListener(Event.COMPLETE,onHTMLcomplete);

       

      After loading the first page (which is about 768 pixels in height) if the viewer of the web page selects a link which is has a larger height - that is shown properly in the following properties.  However, when a shorter page is loaded the height is always the larger height number - it does not change back to 768.  These are the properties I am looking at:

       

      contentHeight and height) in any of the following:

      event.currentTarget.contentHeight or

      event.target.contentHeight or

      html.htmlLoader.window.document.body ...

       

      My question is - after loading the initial page via the mx:HTML statement - after the user clicks on a link which loads a longer page (i.e. the height is larger) - and then the user loads a page which is shorter - the height remains the larger number. 

       

      How do I find the true height of the loaded page (I am checking in the HTML_RENDER event as well as HTML_DOM_INITIALIZE and COMPLETE).

       

      Thanks!

        • 2. Re: Flex 4.6 - how to obtain the true height of a loaded HTML page
          sgfone Level 1

          Well - finally figured it out.  To set the height of the loaded web page so the scroll bars were correct - I did this:

           

          ================  =====================================

          if(browserInsideFlex.htmlLoader.window.document.body.clientHeight)    // make sure this is not null (which can be at the start)

                          {

                              if (browserInsideFlex.htmlLoader.window.document.body.clientHeight > Number(arrOfParms[3]))

                                  {

                                      browserInsideFlex.height = browserInsideFlex.htmlLoader.window.document.body.clientHeight;

                                  }

                                  else

                                  {

                                      browserInsideFlex.height = Number(arrOfParms[3]);

                                  }

                          }

          ================  =====================================

          the "browserInsideFlex" is the ID of an <mx:HTML> and the "Number(arrOfParms[3])" is the height of the AIR program loaded HTML page (which is our case is dynamic - the height changes based on a call to the AIR program).

           

          the "browserInsideFlex.htmlLoader.window.document.body.clientHeight" is the actual/real height of the loaded web page (the web page that was loaded while the user was interacting with the page that this program loaded previously by the AIR program).

           

          Hope this helps someone - it took a while to determine the 2 keys - "browserInsideFlex.htmlLoader.window.document.body.clientHeight" and "browserInsideFlex.height".

          The above code is in the HTML_RENDER event handler (browserInsideFlex.addEventListener(Event.HTML_RENDER, onHTMLrender);)