指定包含元素或 TextRange 对象中一行文本的矩形
var rect = el.getBoundingClientRect();
获取元素的绝对位置:
var left = rect.left
var top = rect.top
var right = rect.right
var bottom = rect.bottom
var width = rect.width,//IE中无法获取
var height = rect.height;//IE中无法获取
function getPos(obj) { return { top : document.documentElement.scrollTop + obj.getBoundingClientRect().top, left : document.documentElement.scrollLeft + obj.getBoundingClientRect().left }; }