screen.availHeight和window.height()之间的区别 [英] Difference between screen.availHeight and window.height()

查看:377
本文介绍了screen.availHeight和window.height()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在浏览器(Firefox)上执行以下Javascript。

I am executing the following Javascript on my browser (Firefox).


  1. console.debug(Screen height = + screen.availHeight ); //输出 770

console.debug(Window Height =+ $(window).height() ); //输出 210 (我也使用jQuery)

console.debug("Window Height ="+ $(window).height()); //outputs 210 (I am using jQuery as well)

有什么区别两者之间?是770像素和210毫米?

What is the difference between the two? Is 770 in pixels and 210 in mm?

同样,当我写 $(文件).height() $(窗口).height(),有区别。是什么原因?

Similarly, when I write $(document).height() and $(window).height(), there is a difference. What is the reason?

推荐答案

window.outerHeight



这是屏幕上窗口的高度,它包括页面和所有可见浏览器的栏(位置,状态,书签,窗口标题,边框......)。

window.outerHeight

It's the height of the window on screen, it includes the page and all the visible browser's bars (location, status, bookmarks, window title, borders, …).

与jQuery的 $(窗口).outerHeight()相同。

This not the same as jQuery's $(window).outerHeight().

这是视口的高度,显示网站,只显示内容,没有浏览器栏。

It's the height of the viewport that shows the website, just the content, no browser's bars.

它是视口中显示的文档高度。如果它高于 $(窗口)。高度(),你会得到滚动条来滚动文档。

It's the height of your document shown in the viewport. If it is higher than $(window).height() you get the scrollbars to scroll the document.

这是浏览器窗口最大化时的高度,包括浏览器栏。所以当窗口最大化时, screen.availHeight === window.outerHeight

It's the height the browser's window can have if it is maximized, including the browser's bars. So when the window is maximized, screen.availHeight === window.outerHeight

它只是匹配屏幕的分辨率。所以在1920×1080的屏幕上, screen.height 1080

It simply matches the screen's resolution. So on a 1920×1080 screen, screen.height will be 1080.

screen.availHeight 等于[ screen.height +操作系统的条形图],如Windows上的任务栏,OS X上的停靠栏和菜单,或者如果您使用的是Linux,屏幕顶部或底部的任何内容都已修复。

screen.availHeight is equal to [screen.height + the operating system's bars], like the taskbar on Windows, the dock and menu on OS X, or whatever is fixed on top or bottom of your screen if you're using Linux.

这篇关于screen.availHeight和window.height()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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