Click to See Complete Forum and Search --> : Where can i find the browser's vissible viewport?


McBiks
03-18-2003, 08:28 AM
Hi again,

I have a question about the browser's veiwport. I'ts about the document.body.offsetWidth and offsetHeight. As I can see - it refeers to the total widht and height in the browser, not the VISIBLE width and height!

I'm interest in placing af DIV in center of the visible part of the browser's viewport. That is if there is scroll-bar, and the user scroll down on the page, and 'opens' a DIV (hidden/vissible), then i want it placed in center on the browser's vissible part of the viewport.
I tried to do that with the body.offsetHeight but the DIV is placed according to the total heigth of the browsers viewport, not the vissible height.

Hmmm - kind of difficult to explain:p

Hope You can give a hint:)

Regards,
Claus

gil davis
03-18-2003, 09:11 AM
Perhaps this will help

http://msdn.microsoft.com/workshop/Author/om/measuring.asp

McBiks
03-18-2003, 09:16 AM
Well! I've looked at this one. The problem is that the body.clientHeight is the total height of the browser's wiewport. If you have a scrollbar on the page, it is the total height, not the vissible height:(

Regards,
Claus

gil davis
03-18-2003, 09:19 AM
Use a "fudge factor". Estimate the size of the scroll bars, and subtract it out. You can tell if the scrollbars are visible.