我怎样才能得到windowWidth
、windowHeight
、pageWidth
、pageHeight
、screenWidth
、screenHeight
、pageX
、pageY
、screenX
、screenY
,它们在所有主要浏览器中都能工作?
我怎样才能得到windowWidth
、windowHeight
、pageWidth
、pageHeight
、screenWidth
、screenHeight
、pageX
、pageY
、screenX
、screenY
,它们在所有主要浏览器中都能工作?
您可以使用jQuery获得窗口或文档的大小:
// Size of browser viewport.
$(window).height();
$(window).width();
// Size of HTML document (same as pageHeight/pageWidth in screenshot).
$(document).height();
$(document).width();
对于屏幕大小,可以使用screen
对象:
window.screen.height;
window.screen.width;