Obtaining the actual size of the html document's body

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anyone know how to obtain the true size of the html document's body? The
control contains the size that the control was set to. The body object
appears to contain the same size. That information must be stored somewhere
in order for the scroll bars to be enabled when the body is larger than the
container.
Also, I have noticed that if I initialize the control with a large size, the
vertical scrollbar is disabled, but is still visible, while the horizontal
scrollbar is invisible. Is there any way to hide both?
 
Thanks for the links. They gave me something further to investigate.
Unfortunately, it didn't help.
When I obtain the clientHeight and clientWidth via the IHTMLElement2
interface I receive 0. I tried against both the body and the document
elements, as shown below.
If I use the document element's scrollWidth and scrollHeight, the values are
close but I still have both scroll bars. Placing the body context within an
absolute positioned DIV did not remove the scrollbars.

If you have any further suggestions or a clue as to why the clientHeight and
clientWidth are 0, I'd appreciate it.

Thanks!

private void axWebBrowser1_DocumentComplete (Object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
if ( ( (int)axWebBrowser1.get_ReadyState() >= 4) &
( ! axWebBrowser1.get_Busy() ))
{
HTMLDocumentClass doc = (HTMLDocumentClass)axWebBrowser1.get_Document();
IHTMLElement2 body = (IHTMLElement2)doc.get_body();
IHTMLElement2 docElem = (IHTMLElement2)doc.get_documentElement();
int width = docElem.get_clientWidth();
int height = docElem.get_clientHeight();
axWebBrowser1.set_Width(width);
axWebBrowser1.set_Height(height);
}
}
 
Back
Top