PDA

View Full Version : information about caretPos


jolietjake
10-29-2002, 09:11 AM
Hello, I have found this code:

<HTML>
<HEAD>
<SCRIPT>
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 = "<b>"+caretPos.text+"</b>";//caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
alert (caretPos+" ");
}
else textEl.value = text;

}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="aForm">
<TEXTAREA NAME="aTextArea" ROWS="5" COLS="80" WRAP="soft" ONSELECT="storeCaret(this);" ONCLICK="storeCaret(this);" ONKEYUP="storeCaret(this);" > Kibology for all. All for Kibology. </TEXTAREA>
<BR>
<INPUT TYPE="text" NAME="aText" SIZE="80" VALUE="Scriptology">
<BR>
<INPUT TYPE="button" VALUE="insert at caret" ONCLICK="insertAtCaret(this.form.aTextArea, this.form.aText.value); ">
</FORM>
</BODY>
</HTML>

And I want some information about the caretPos element, like his properties and functions. Can someone give me a link? Thanks

beetle
10-29-2002, 07:42 PM
There is no caretPos object/property....the script above creates it from a degenerate textRange

i.e. caretPos is custom property for this script...

So, it should have all the same properties as a textRange object...

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_textrange.asp