获取屏幕大小、当前网页和浏览器窗口 [英] Get the size of the screen, current web page and browser window

查看:35
本文介绍了获取屏幕大小、当前网页和浏览器窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取windowWidthwindowHeightpageWidthpageHeightscreenWidth>、screenHeightpageXpageYscreenXscreenY所有主流浏览器?

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;

这篇关于获取屏幕大小、当前网页和浏览器窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆