Click to See Complete Forum and Search --> : Determining the browser client area ...


SergMour
May 10th, 2002, 12:36 PM
Hi everyone,

Can anybody help me determine the size of a browsers client area (in px and JavaScript) ? I need to process onresize event for doc's body and resize my picture accordingly. Thanks in advance.
Sergei

anupam kant
May 14th, 2002, 06:57 AM
try this

pxHeight = window.document.body.clientHeight;
pxWidth = window.document.body.clientWidth;
or
pxHeight = window.document.body.offsetHeight;
pxWidth = window.document.body.offsetWidth;

whichever suites your reaquirement.

Anupam.
PI Softek Ltd. India

SergMour
May 14th, 2002, 09:23 AM
Yes, thanks. I'm already using it. This forum is pretty slow even for these simple things. By the way, I resize the browser window based on the size of pictures I load into the page dinamically. I use the same html page to load any picture as in the excerpt below:

var w=window.open("showpic.htm","_blank",strOpenParams);
w.focus();

var pic = w.document.createElement("img");
pic.setAttribute("alt",strDescription);
pic.setAttribute("src",phref);
while( ! w.document.body ){} // Wait until new doc loads and body element exists
w.document.body.appendChild(pic);
w.document.images[0].width=picWidth;
w.document.images[0].height=picHeight;
w.resizeTo(pX,pY);




Later in 'showpic.htm' I use window.resizeTo(...) and window.resizeBy(...) extensively. I am concerned that these functions may not work properly in netscape or IE 4.01. I would appreciate any suggestions.
Sergei