以下都不行:
function getOffset(e) {
var t = e.offsetTop;
var l = e.offsetLeft;
while (e = e.offsetParent) {
t += e.offsetTop;
l += e.offsetLeft;
}
var rec = new Array(1);
rec[0] = t;
rec[1] = l;
return rec;
}
function getPoint(source) {
var pt = { x: 0, y: 0 };
// do {
// pt.x += source.offsetLeft;
// pt.y += source.offsetTop;
// source = source.offsetParent;
// }
// while (source);
pt.x = source.getBoundingClientRect().left + getHScroolPos();
pt.y = source.getBoundingClientRect().top + getVScroolPos();
return pt;
}