Thursday, October 12, 2017

Find position of object in the screen

Tested it, it works pretty nice in FF, Chrome, IE, Safari too.
function resetPosition(object, args) {
/* find the textbox object */
var tb = object._element;
/* measure textbox height */
var tbheight = tb.offsetHeight;
/* find textbox in the page */
var rect = tb.getBoundingClientRect();
var divleft = Math.floor(rect.left);
var divtop = Math.floor(rect.top + tbheight);
/* find the auto complete extender div in the page */
var ex = object._completionListElement;
/* move the ace to the right position */
if (ex)
$common.setLocation(ex, new Sys.UI.Point(divleft, divtop));
}