Get the size of the screen, current web page and browser window(获取屏幕、当前网页和浏览器窗口的大小)
问题描述
如何获取 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;
这篇关于获取屏幕、当前网页和浏览器窗口的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取屏幕、当前网页和浏览器窗口的大小


基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- npm start 错误与 create-react-app 2022-01-01