<html>
<head>
<script language="javascript">
<!--[highlight #f0f0f0]
[blue]function[/blue] saveCaret(otxt)
{
[blue]if[/blue] (otxt.isTextEdit)
[blue]if[/blue] (document.selection)
otxt.caretPos [COLOR=magenta]=[/color] [blue]document[/blue].selection.createRange().duplicate();
}
[blue]function[/blue] getCaretPos(otxt)
{
[blue]if[/blue] ( otxt.isTextEdit [COLOR=magenta]&&[/color] otxt.caretPos )
{
otxt.focus();
[blue]var[/blue] bookmark [COLOR=magenta]=[/color] [red]"~!~"[/red];
[blue]var[/blue] caretPos [COLOR=magenta]=[/color] otxt.caretPos;
caretPos.collapse([blue]true[/blue]);
[blue]var[/blue] origCaret [COLOR=magenta]=[/color] caretPos.text;
caretPos.text [COLOR=magenta]=[/color] bookmark;
[blue]var[/blue] i_caretPos [COLOR=magenta]=[/color] otxt.value.search( bookmark );
[blue]window[/blue].status [COLOR=magenta]=[/color] [red]"Caret is at character "[/red] [COLOR=magenta]+[/color] i_caretPos;
caretPos.moveStart([red]'character'[/red],(0 [COLOR=magenta]-[/color] bookmark.length));
caretPos.execCommand([red]'Delete'[/red]);
[blue]return[/blue] i_caretPos;
}
}
[/highlight]//-->
</script>
</head>
<body>
<textarea id="txtcanvas"
style="width:100%;height:100px;"
onkeydown="saveCaret(this);getCaretPos(this);"
onkeyup="saveCaret(this);getCaretPos(this);"
></textarea>
</body>
</html>