PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 25 → WB - Detectar a área útil do navegador
WB - Detectar a área útil do navegador
Iniciado por BOLLER, 16,ene. 2017 18:14 - No hay respuesta
Miembro registrado
3.659 mensajes
Popularité : +175 (223 votes)
Publicado el 16,enero 2017 - 18:14
Prezados,

CODIGO QUE DETECTA A AREA UTIL DO NAVEGADOR

function detectBrowserSize() {
var myWidth = 0, myHeight = 0;
if (typeof (window.innerWidth) == 'number') {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
alert(myWidth + ' - ' + myHeight)
}

//http://stackoverflow.com/questions/1587499/detecting-browser-client-area-size-on-wide-screen-using-javascript


Engraçado que no IE aqui, so consegui ler o Width... o Height so dava 0 (zero).
Consegui resolver utilizando isso:

document.body.clientWidth
document.body.clientHeight

Isso no caso de IE... Com outros browser o innerwidth e height funciona beleza.

No caso, eu tb precisei fazer um evento de drag e drop mas sem deixar dar overflow.
o trecho citado acima ficou assim:

function detectBrowserSize() {
if (navigator.appName.indexOf("Microsoft")!=-1)
{
w = document.body.clientWidth;
h = document.body.clientHeight;
}
else
w = window.innerWidth;
h = window.innerHeight;

// objW e objH relacionados abaixo é o width e height do objeto que sofrera o drag e drop
// acrescentei + 10 pra não ficar colado nas bordas finais.

limitDragX = w - (objW + 10);
limitDragY = h - (objH + 10);
}


:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/