“Tamaño de la ventana de JavaScript” Código de respuesta

Cómo obtener la altura de la ventana en JavaScript

//get screen height of the device by using
window.innerHeight
//get screen width of the device by using
window.innerWidth
Pleasant Partridge

Obtener el tamaño de la ventana JavaScript

const window {
  width: window.innerWidth,
  height: window.innerHeight
}
Cheerful Cockroach

Dimensiones de la ventana JS

// better than using window.innerWidth / window.innerHeight 
// because of scrollbars
const client = {
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight
}
P.S.

JS Check Window Width

// Size of browser viewport.
$(window).height();
$(window).width();

// Size of HTML document (same as pageHeight/pageWidth in screenshot).
$(document).height();
$(document).width();
Cheerful Cheetah

Cómo obtener el tamaño de la ventana en JavaScript

var win = window,
    doc = document,
    docElem = doc.documentElement,
    body = doc.getElementsByTagName('body')[0],
    x = win.innerWidth || docElem.clientWidth || body.clientWidth,
    y = win.innerHeight|| docElem.clientHeight|| body.clientHeight;
alert(x + ' × ' + y);
Arex

Tamaño de la ventana de JavaScript

let w = window.innerWidth;
let h = window.innerHeight;
naly moslih

Respuestas similares a “Tamaño de la ventana de JavaScript”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código