如何取到一个控件的位置
getAbsolutePos = function(el) {
var r = { x: el.offsetLeft, y: el.offsetTop };
if (el.offsetParent) {
var tmp = getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
};
var el=document.getElementById("flg");
var objs=getAbsolutePos(el);
var y=objs.y+document.form1.flg.offsetHeight;
var x=objs.x;
取到flg的位置
var r = { x: el.offsetLeft, y: el.offsetTop };
if (el.offsetParent) {
var tmp = getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
};
var el=document.getElementById("flg");
var objs=getAbsolutePos(el);
var y=objs.y+document.form1.flg.offsetHeight;
var x=objs.x;
取到flg的位置
posted on 2007-01-24 19:30 freeliver54 阅读(572) 评论(0) 编辑 收藏 举报