javascript javascript中screen.width和screen.availwidth的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5456582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
screen.width and screen.availwidth difference in javascript
提问by SilverLight
What is the difference between screen.width
and screen.availwidth
in JavaScript?
JavaScript 中screen.width
和之间有什么区别screen.availwidth
?
On my system both are the same!
在我的系统上两者都是一样的!
采纳答案by alex
Some things block some of your viewport, such a history/bookmarks side panel. This includes the taskbar, unless it's on Autohide
有些东西会挡住您的某些视口,例如历史记录/书签侧面板。这包括任务栏,除非它在自动隐藏上
Then window.screen.width != window.screen.availWidth
. :)
然后window.screen.width != window.screen.availWidth
。:)
If you are drawing things to the viewport, you ought to use availWidth
/ availHeight
to determine if things are off the viewport etc. Be sure to recalculate on window resize otherwise you won't know when the sidepanel has been closed.
如果你正在向视口绘制东西,你应该使用availWidth
/availHeight
来确定东西是否离开视口等。一定要重新计算窗口大小,否则你将不知道侧面板何时关闭。
Note that not all of the width given by this property may be available to the window itself. When other widgets occupy space that cannot be used by the window object, there is a difference in window.screen.width and window.screen.availWidth.
请注意,并非此属性给出的所有宽度都可用于窗口本身。当其他widget占用了window对象不能使用的空间时,window.screen.width和window.screen.availWidth是有区别的。
来源。
回答by Ema.H
window.screen.width -> Returns the width of the screen.
window.screen.width -> 返回屏幕的宽度。
window.screen.availWidth -> Returns the amount of horizontal space in pixels availableto the window.
window.screen.availWidth -> 返回窗口可用的水平空间量(以像素为单位)。
It is best to use availWidth for the exact size available for our component example.
最好使用availWidth 作为我们组件示例可用的确切大小。