hello i have some problem with my javascript code..
i want to get xy position the selected text in javascript, and i use offside function like this :
function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
while(1)
{
curleft += obj.offsetLeft;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.x)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
while(1)
{
curtop += obj.offsetTop;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.y)
curtop += obj.y;
return curtop;
}
but the result of position X,Y always 0 when i call this function to find position selected text
var select = window.getSelection();
var posX = findPosX(select);
var posY = findPosY(select);
and i use mozilla firefox.. please help me