js|js 获取元素相对于窗口的定位

var box = document.getElementById("box");
【js|js 获取元素相对于窗口的定位】var pos = box.getBoundingClientRect(); //此方法
box.innerHTML = "top:"+pos.top +
"left:"+pos.left +
"bottom:"+pos.bottom +
"right:"+pos.right +
"width:"+pos.width +
"height:"+pos.height

    推荐阅读