Article Introduction: JS Gets the browser window wide and the width of the page is high. |
JS access to the browser window width and width of the page height:
/**
/Third FUNCTION
* GetPageSize () by webjx.com
*
* @return Array return a array with page width, height and window width, height
*/
function ___getpagesize () {
var xscroll, Yscroll;
if (window.innerheight && window.scrollmaxy) {
Xscroll = window.innerwidth + Window.scrollmaxx;
Yscroll = Window.innerheight + window.scrollmaxy;
else if (Document.body.scrollHeight > Document.body.offsetHeight) {//all but Explorer Mac
Xscroll = Document.body.scrollWidth;
Yscroll = Document.body.scrollHeight;
else {//Explorer mac...would also work in Explorer 6 Strict, Mozilla and Safari
Xscroll = Document.body.offsetWidth;
Yscroll = Document.body.offsetHeight;
}
var windowwidth, WindowHeight;
if (self.innerheight) {//all except Explorer
if (document.documentElement.clientWidth) {
WindowWidth = Document.documentElement.clientWidth;
} else {
WindowWidth = Self.innerwidth;
}
WindowHeight = Self.innerheight;
else if (document.documentelement && document.documentElement.clientHeight) {//Explorer 6 Strict Mode
WindowWidth = Document.documentElement.clientWidth;
WindowHeight = Document.documentElement.clientHeight;
else if (document.body) {//other explorers
WindowWidth = Document.body.clientWidth;
WindowHeight = Document.body.clientHeight;
}
For small pages and total height less then height of the viewport
if (Yscroll < WindowHeight) {
PageHeight = WindowHeight;
} else {
PageHeight = Yscroll;
}
For small pages and total width less then width of the viewport
if (Xscroll < windowwidth) {
PageWidth = Xscroll;
} else {
PageWidth = WindowWidth;
}
Arraypagesize = new Array (pagewidth,pageheight,windowwidth,windowheight);
return arraypagesize;
};