js之可移植的查询窗口大小和位置
来源:互联网 发布:淘宝上新频率 编辑:程序博客网 时间:2024/03/29 01:36
var Geometry = {};
if(window.screenLeft){ //IE and others
Geometry.getWindowX = function(){return window.screenLeft;};
Geometry.getWindowY = function(){return window.screenTop;};
}
else if{ //Firefox and others
Geometry.getWindowX = function(){return window.screenX;};
Geometry.getWindowY = function(){return window.screenY;};
}
if(windows.innerWidth){ //All browsers but IE
Geometry.getViewportWidth = function(){return windows.innerWidth;};
Geometry.getViewportHeight = function(){return windows.innerHeight ;};
Geometry.getHorizontalScroll = function(){return window.pageXOffset;};
Geometry.getVerticalScroll = function(){return window.pageYOffset;};
}
else if(document.documentElement && document.documentElement.clientWidth){
//These functions are for IE6 when there is a DOCTYPE
Geometry.getViewportWidth = function(){return document.documentElement.clientWidth};
Geometry.getViewportHeight = function(){return document.documentElement.clientHeight};
Geometry.getHorizontalScroll = function(){return document.documentElement.scrollLeft;};
Geometry.getVerticalScroll = function(){return document.documentElement.scrollTop;};
}
else if(document.body.clientWidth){
//These are for IE4,IE5,and IE6 without a DOCTYPE
Geometry.getViewportWidth = function(){return document.body.clientWidth};
Geometry.getViewportHeight = function(){return document.body.clientHeight};
Geometry.getHorizontalScroll = function(){return document.body.scrollLeft;};
Geometry.getVerticalScroll = function(){return document.body.scrollTop;};
}
//These functions return the size of the document.They are not window related,but they are
//useful to have here anyway
if(document.documentElement && document.documentElement.scrollWidth){
Geometry.getDocumentWidth = function(){return document.documentElement.scrollWidth;};
Geometry.getDocumentHeight = function(){return document.documentElement.scrollHeight;};
}
else if(document.body.scrollWidth){
//适用于IE4,IE5,and IE6 without a DOCTYPE,以及chrome,firefox等其他浏览器
Geometry.getDocumentWidth = function(){return document.body.scrollWidth;};
Geometry.getDocumentHeight = function(){ return document.body.scrollHeight;};
}
0 0
- js之可移植的查询窗口大小和位置
- JS弹出窗口窗口的位置和大小
- JS弹出窗口窗口的位置和大小
- js之获取窗口大小和位置信息
- 取得窗口大小和窗口位置-兼容所有浏览器的js代码
- 改变浏览器窗口的大小和位置
- 记录窗口的位置和大小
- Qt 获取窗口的位置和大小
- MFC窗口位置和大小的获取
- android 可自定义大小和位置的Dialog
- js 控制浏览器窗口位置,大小
- 设置窗口的客户区大小和位置
- 如何设置一个窗口的大小、位置和其他参数
- 如何设置应用程序窗口的初始大小和位置
- 控件的大小和位置随窗口变化
- 改变单文档应用程序窗口的大小和位置
- unity里设置窗口大小和位置的代码
- 跨浏览器用javascript获取窗口的位置和大小
- Visual Studio 2013 设置成为 Unity 3D 默认编辑器的方法
- js之提取URL中的参数
- SuperSocket服务器架设(四):我的AppSession连接管理方案(简单版)
- js之获取窗口大小和位置信息
- Struts2文件上传
- js之可移植的查询窗口大小和位置
- js之Window对象方法示例
- 从头开始学COCOS2DXb笔记四(导入COCOS2DX ANDROID官方示例)
- js之帧中的导航栏
- -/bin/sh: XXX: not found
- Android笔记 - UI Menu (3) Action Bar
- js权威指南之事件和事件处理
- 一个JavaScript问题引发的思考
- 处理按键事件的js模块