R
ReGenesis0
Is it possible to determine the caret position, in terms of x/y
pixels, within a textarea? (I want to have a suggestion box pop up
under where you're typing... so i need to determine where you are
typing.)
-Derik
(OTOH, finding the Caret position-- between what characters the cursor
is positioned-- uses the function below. I include it to be nice to
future searchers, and because it took me an hour of frustrated
searching to find.)
function getCaretPos(el) {
if (typeof el.selectionStart != 'undefined')
return el.selectionStart;
else if (document.selection)
return
Math.abs(document.selection.createRange().moveStart('character',
-1000000));
}
pixels, within a textarea? (I want to have a suggestion box pop up
under where you're typing... so i need to determine where you are
typing.)
-Derik
(OTOH, finding the Caret position-- between what characters the cursor
is positioned-- uses the function below. I include it to be nice to
future searchers, and because it took me an hour of frustrated
searching to find.)
function getCaretPos(el) {
if (typeof el.selectionStart != 'undefined')
return el.selectionStart;
else if (document.selection)
return
Math.abs(document.selection.createRange().moveStart('character',
-1000000));
}