Gaunam darbinio lango dydį ir plotį
Bir.02, 2007 in
Javascript, Programavimas, WEB programavimas
Kartais mum reikia sužinoti darbinio lango dydį bei plotį. Galima pačiam pasirašyti funkciją, tačiau ji gali veikti ne visose naršyklėse. Šios dvi funkcijos veikė ant mano išbandytų naršyklių (IE6,IE7,opera,firefox,maxthon):
-
function getWindowHeight() {
-
var iwindowHeight = 0;
-
if (typeof(window.innerHeight) == ‘number’) {
-
iwindowHeight = window.innerHeight;
-
}
-
else {
-
if (document.documentElement && document.documentElement.clientHeight) {
-
iwindowHeight = document.documentElement.clientHeight;
-
}
-
else {
-
if (document.body && document.body.clientHeight) {
-
iwindowHeight = document.body.clientHeight;
-
}
-
}
-
}
-
return iwindowHeight;
-
}
-
function getWindowWidth() {
-
var iWindowWidth = 0;
-
if (typeof(window.innerWidth) == ‘number’) {
-
iwindowWidth = window.innerWidth;
-
}
-
else {
-
if (document.documentElement && document.documentElement.clientWidth) {
-
iwindowWidth = document.documentElement.clientWidth;
-
}
-
else {
-
if (document.body && document.body.clientWidth) {
-
iwindowWidth = document.body.clientWidth;
-
}
-
}
-
}
-
return iwindowWidth;
-
}


Birželis 2nd, 2007 at 18:59:53
[...] Gaunam darbinio lango dydį ir plotį [...]