P
Paul Gorodyansky
Hi,
Say I have a text in my TEXTAREA box - 01234567890
I want - using script - insert say "abc" in the middle.
Works almost OK in Internet Explorer (with one problem) based on their
example at
http://msdn.microsoft.com/library/en-us/dnwebteam/html/webteam12032001.asp
in the chapter "O Cursor, Where Art Thou".
Here is what happens (I use caretPos.text = "abc"
:
1. If no text is selected - no problem, my "abc" got inserted say
after '2' AND I see a Caret (vertical bar) after it
2. But if - with the same code - I _select_ say "56" and want to
override it with "abc", then yes, "56" got replaced with "abc",
BUT there is no Caret symbol on screen, no vertical bar!
Is it solvable?
You can see the code working by typing say 0123456789, selecting
several digits and then clicking with a mouse on any
letter of a keyboard image:
http://RusWin.net/screen_e.htm
(in that specific mouse-driven mode a replacement is one symbol, but
in other modes it's not the case, the replacement could be a _string_)
The script piece is below.
--
Regards,
Paul Gorodyansky
"Cyrillic (Russian): instructions for Windows and Internet":
http://RusWin.net
Russian On-screen Keyboard: http://Kbd.RusWin.net
========== Script piece
// elem is a TEXTAREA object
function getCaretPos(elem, newString)
{
if ( elem.isTextEdit )
{
if ( !elem.caretPos )
saveCaret(elem);
var caretPos = elem.caretPos;
caretPos.text = newString;
}
}
function saveCaret(elem)
{
if ( elem.isTextEdit )
elem.caretPos = document.selection.createRange();
}
// HTML piece:
<textarea name='message' ONSELECT='saveCaret(this)'
ONCLICK='saveCaret(this)' ONKEYUP='saveCaret(this)'
</textarea>
Say I have a text in my TEXTAREA box - 01234567890
I want - using script - insert say "abc" in the middle.
Works almost OK in Internet Explorer (with one problem) based on their
example at
http://msdn.microsoft.com/library/en-us/dnwebteam/html/webteam12032001.asp
in the chapter "O Cursor, Where Art Thou".
Here is what happens (I use caretPos.text = "abc"
1. If no text is selected - no problem, my "abc" got inserted say
after '2' AND I see a Caret (vertical bar) after it
2. But if - with the same code - I _select_ say "56" and want to
override it with "abc", then yes, "56" got replaced with "abc",
BUT there is no Caret symbol on screen, no vertical bar!
Is it solvable?
You can see the code working by typing say 0123456789, selecting
several digits and then clicking with a mouse on any
letter of a keyboard image:
http://RusWin.net/screen_e.htm
(in that specific mouse-driven mode a replacement is one symbol, but
in other modes it's not the case, the replacement could be a _string_)
The script piece is below.
--
Regards,
Paul Gorodyansky
"Cyrillic (Russian): instructions for Windows and Internet":
http://RusWin.net
Russian On-screen Keyboard: http://Kbd.RusWin.net
========== Script piece
// elem is a TEXTAREA object
function getCaretPos(elem, newString)
{
if ( elem.isTextEdit )
{
if ( !elem.caretPos )
saveCaret(elem);
var caretPos = elem.caretPos;
caretPos.text = newString;
}
}
function saveCaret(elem)
{
if ( elem.isTextEdit )
elem.caretPos = document.selection.createRange();
}
// HTML piece:
<textarea name='message' ONSELECT='saveCaret(this)'
ONCLICK='saveCaret(this)' ONKEYUP='saveCaret(this)'
</textarea>