自定义函数

//跨浏览器的方法

var leftX = (typeof screenLeft == 'number') ? screenLeft : screenX;
var topY = (typeof screenTop == 'number') ? screenTop : screenY;

//可视窗口的宽和高

var width = window.innerWidth; //这里要加window,因为IE 会无效
var height = window.innerHeight;
if (typeof width != 'number') { //如果是IE,就使用document
if (document.compatMode == 'CSS1Compat') {
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
} else {
width = document.body.clientWidth; //非标准模式使用body
height = document.body.clientHeight;
}
}

 

posted @ 2015-03-24 21:35  laugh  阅读(125)  评论(0编辑  收藏  举报