javascript 获取元素相对于浏览器的位置 ie 5,6,7,8,9,10 测试通过
dom中的每个元素节点都有一个相对于父节点的布局定位属性offsetLeft,offsetTop
getPosition: function (el) { _x = 0, _y = 0; while (el.offsetParent !== null) { _x += el.offsetLeft; _y += el.offsetTop; el = el.offsetParent; } return { x: _x, y: _y }; }