R
reflex
Hi,
I am making google like suggest, but i have big problem with
positioning absolute positioned div, which has to be under input,
where users enter text.
I am using this function:
function get_element_pos(obj){
var yOffset = obj.offsetTop||0;
var xOffset = obj.offsetLeft||0;
elParent = obj.offsetParent;
while(elParent){
yOffset += (elParent.offsetTop||0);
xOffset += (elParent.offsetLeft||0);
elParent = elParent.offsetParent;
}
var readScroll;
if((window.document.compatMode)&&
(window.document.compatMode == 'CSS1Compat')){
readScroll = window.document.documentElement;
}else{
readScroll = window.document.body;
}
xOffset -= (readScroll.scrollLeft - readScroll.clientLeft);
yOffset -= (readScroll.scrollTop - readScroll.clientTop);
return {x:xOffset,y:yOffset};
}
It returns right value, if it is not inside div with overflow: auto
Any suggestion?
Thx
reflex
I am making google like suggest, but i have big problem with
positioning absolute positioned div, which has to be under input,
where users enter text.
I am using this function:
function get_element_pos(obj){
var yOffset = obj.offsetTop||0;
var xOffset = obj.offsetLeft||0;
elParent = obj.offsetParent;
while(elParent){
yOffset += (elParent.offsetTop||0);
xOffset += (elParent.offsetLeft||0);
elParent = elParent.offsetParent;
}
var readScroll;
if((window.document.compatMode)&&
(window.document.compatMode == 'CSS1Compat')){
readScroll = window.document.documentElement;
}else{
readScroll = window.document.body;
}
xOffset -= (readScroll.scrollLeft - readScroll.clientLeft);
yOffset -= (readScroll.scrollTop - readScroll.clientTop);
return {x:xOffset,y:yOffset};
}
It returns right value, if it is not inside div with overflow: auto
Any suggestion?
Thx
reflex