获取屏幕、当前网页和浏览器窗口的大小
如何获取 windowWidth
、windowHeight
、pageWidth
、pageHeight
、screenWidth
, screenHeight
, pageX
, pageY
, screenX
, screenY
所有主流浏览器?
How can I get windowWidth
, windowHeight
, pageWidth
, pageHeight
, screenWidth
, screenHeight
, pageX
, pageY
, screenX
, screenY
which will work in all major browsers?
推荐答案
可以通过jQuery获取窗口或文档的大小:
You can get the size of the window or document with jQuery:
// Size of browser viewport.
$(window).height();
$(window).width();
// Size of HTML document (same as pageHeight/pageWidth in screenshot).
$(document).height();
$(document).width();
对于屏幕大小,您可以使用 screen
对象:
For screen size you can use the screen
object:
window.screen.height;
window.screen.width;
相关文章