Hi All,
How can I get the start and end selection indices in browsers other than IE in contentEditable 'div'. For Ex., IE has the following method.
var oSelection;
var oTxtRange;
var units = -100000;
var iStartIndex = -1, iEndIndex = -1;
if(document.selection) // IE..
{
oSelection = document.selection;
oTxtRange = oSelection.createRange();
if(oTxtRange)
{
iStartIndex = oTxtRange.moveStart('character',units);
iEndIndex = oTxtRange.moveEnd('character',units);
iStartIndex *= -1;
iEndIndex *= -1;
}
}
I understand that above method is not a W3C standard. I have gone through W3C documentation for Selection and Range object, but still couldn't help finding solution for Chrome and FireFox. Solution in JQuery is also welcome.
Thanks in Advance :-)