问题描述
window.outerHeight/window.outerWidth
window.outerHeight / window.outerWidth
此值不是以像素为单位吗?
are this values not in pixels ?
http://www.w3schools.com/jsref/tryit.asp? filename = tryjsref_win_inner_outer
(屏幕为2560)
Firefox外部宽度:2576
边缘外宽度:3435
chrome外部宽度:2560
IE外宽度:2862
(screen is 2560)
firefox outerWidth: 2576
edge outerWidth: 3435
chrome outerWidth: 2560
IE outerWidth: 2862
这是什么值?
如何获取以像素为单位的屏幕尺寸?
how can i get the screen size in pixels ?
推荐答案
//如果需要屏幕的宽度和高度
//if you need the screen width and height
//屏幕高度
var height = screen.height
//屏幕宽度
var width = screen.width
//如果您想知道使用的代码做什么:
//if you want to know what the code you use do:
获取窗口的高度和宽度:(包括工具栏/滚动条):
Get the window's height and width: (including toolbars/scrollbars):
var w = window.outerWidth;
var h = window.outerHeight;
来源: http://www.w3schools.com/jsref/prop_win_outerheight.asp
获取窗口的高度和宽度:(不包括工具栏/滚动条):
Get the window's height and width: (NOT including toolbars/scrollbars):
var w = window.innerWidth;
var h = window.innerHeight;
来源: http://www.w3schools.com/jsref/prop_win_innerheight.asp
这篇关于window.outerWidth的疯狂值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!