Como sugirió Kyle, puede medir el tamaño de la ventana gráfica del navegador del cliente sin tener en cuenta el tamaño de las barras de desplazamiento de esta manera.
Muestra (dimensiones de la ventana gráfica SIN barras de desplazamiento)
// First you forcibly request the scroll bars to hidden regardless if they will be needed or not.
$('body').css('overflow', 'hidden');
// Take your measures.
// (These measures WILL NOT take into account scroll bars dimensions)
var heightNoScrollBars = $(window).height();
var widthNoScrollBars = $(window).width();
// Set the overflow css property back to it's original value (default is auto)
$('body').css('overflow', 'auto');
Alternativamente, si desea encontrar las dimensiones de la ventana gráfica del cliente teniendo en cuenta el tamaño de las barras de desplazamiento, esta muestra a continuación se adapta mejor a sus necesidades.
Primero, no olvide configurar la etiqueta de su cuerpo para que sea 100% de ancho y alto solo para asegurarse de que la medida sea precisa.
body {
width: 100%; // if you wish to measure the width and take into account the horizontal scroll bar.
height: 100%; // if you wish to measure the height while taking into account the vertical scroll bar.
}
Muestra (dimensiones de la ventana gráfica CON barras de desplazamiento)
// First you forcibly request the scroll bars to be shown regardless if they will be needed or not.
$('body').css('overflow', 'scroll');
// Take your measures.
// (These measures WILL take into account scroll bars dimensions)
var heightWithScrollBars = $(window).height();
var widthWithScrollBars = $(window).width();
// Set the overflow css property back to it's original value (default is auto)
$('body').css('overflow', 'auto');