Get position of an element use Javascript

	    function getPos(el) {
	        if (BrowserHelper.IsIE()) {
	            for (var lx = 0, ly = 0; el != null; ) {
	                lx += el.offsetLeft;
	                ly += el.offsetTop;
	                el = el.offsetParent;
	            }
	            return { x: lx.toString() + "px", y: ly.toString() + "px" };
	        }
	        else {
	            return { x: el.offsetLeft.toString() + "px", y: el.offsetTop.toString() + "px" };
	        } 
	    }
posted @ 2010-04-26 13:41  lp123  阅读(194)  评论(0编辑  收藏  举报