js之获取窗口大小和位置信息

来源:互联网 发布:淘宝上新频率 编辑:程序博客网 时间:2024/04/20 22:55
除IE外的浏览器查看窗口大小和位置信息:
//The overall size of the browser window on the desktop
var windowWidth = window.outerwidth;
var windowHeight = window.outerHeight;

//This is the position of the browser window on the desktop
var windowX = window.screenX;
var windowY = window.screenY;

//The size of the viewport in which the HTML document is displayed
//This is the window size minus the menu bars,toolbars,scrollbars,etc.
var viewportWidth = windows.innerWidth;
var viewportHeight = windows.innerHeight;

//These values specify the horizontal and vertical scrollbar positions.
//They are used to convert between document coordinates and window coordinates.
//These values specify what part of the document appears in the upper-left corner of the screen.
var horizontalScroll = window.pageXOffset;
var verticalScroll = window.pageYOffset;
0 0
原创粉丝点击