Accessing the properties of the current window largely depends on the browser used. As is often the case with JavaScript, the browser world is divided into two groups: Internet Explorer and the rest. With Internet Explorer, the width of a window can be determined via document.body.clientWidth; other browsers use window.innerWidth for the "inner" width (excluding window decoration) and window.outerWidth for the "outer" width (including window decoration). For determining the height, just replace width and Width with height and Height, respectively. The following code outputs the current window's dimensions: Determining the Current Window's Dimensions (dimensions.html)
Tip Note that the page needs a <body> area and the code must not be executed before the page has been fully loaded for the code to work in Internet Explorer. |