Hello,
I'm trying to set the caret position in a contenteditable div layer, and after a bit of searching the web and experimenting I got it to work in firefox using this:
function set(element,position){
element.focus();
var range= window.getSelection().getRangeAt(0);
range.setStart(element.firstChild,position);
range.setEnd(element.firstChild,position);
}
[...]
set(document.getElementById("test"),3);
But in Chrome/webkit it selects all of the content in the div. Is this a bug with webkit or am I doing something wrong?
Thank you in advance.