...

View Full Version : store caret



NetMan
03-03-2003, 05:18 PM
i suppose this question is rather old and had been answered numerous times but i just couldn't find where. so here is the question:
i have


function storeCaret (textEl) {
if (textEl.createTextRange)
textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text =
caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
text + ' ' : text;
}
else
textEl.value = text;
}

i want to write a function that inserts some text and poses a caret after that when i click on the image :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum