且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取屏幕大小、当前网页和浏览器窗口

更新时间:2023-01-27 20:13:16

你可以用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;