471,349 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

Obtaining the actual size of the html document's body

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?
Jul 21 '05 #1
2 5573
Sounds like your after a way to determine the height and width of a
displayed page, which you cant easily do that, but these might help work out
what you are looking for.

http://www.howtocreate.co.uk/tutoria...?tut=0&part=16

http://www.howtocreate.co.uk/perfectPopups.html

If you want no scrollbars, you could wrap your body content in a div and set
the css attribute position: absolute;

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"gregl" <gr***@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
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?

Jul 21 '05 #2
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);
}
}

"John Timney (ASP.NET MVP)" wrote:
Sounds like your after a way to determine the height and width of a
displayed page, which you cant easily do that, but these might help work out
what you are looking for.

http://www.howtocreate.co.uk/tutoria...?tut=0&part=16

http://www.howtocreate.co.uk/perfectPopups.html

If you want no scrollbars, you could wrap your body content in a div and set
the css attribute position: absolute;

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"gregl" <gr***@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
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?


Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Closer | last post: by
10 posts views Thread by Rithish | last post: by
4 posts views Thread by Eduard Witteveen | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.