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
<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