跨浏览器获取位置

var leftX = typeof window.screenLeft == 'number' ? window.screenLeft : window.screenX;
var topY = typeof window.screenTop == 'number' ? window.screenTop : window.screenY;

firefox浏览器不支持screenLeft和scrennTop,但是支持screenX和screenY;ie浏览器支持screenLeft和scrennTop,但是不支持screenX和screenY
跨浏览器获取大小

var width = window.innerWidth;      //window.必须有,因为IE不支持
var height = window.innerHeight; //如果支持inner的,那么就使用它,

//不支持的就是用document对象的方法

if (typeof width != 'number') {
if (document.compatMode == 'CSS1Compat') {
width = document.documentElement.clientWidth; //标准ie
height = document.documentElement.clientHeight;
} else { //非标准ie
width = document.body.clientWidth;
height = document.body.clientHeight;
}
}