By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,175 Members | 1,710 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,175 IT Pros & Developers. It's quick & easy.

Revealing the position of the cursor in a text-area

P: n/a
PeP
Good morning,
I have a form containing a text-area,
I'd like to know if it exists a function that, when I activate an event,
returns the position of the cursor in the text-area.

For example, I write ten words in the text-area,
then I move the cursor at the beginning of the second word
and activate the event (for example, click on a button):
is there a way to know that the cursor is at the beginning of the second
word?

I know that the text-area is considered as a string,
so I want the position of the cursor in that string
at the moment of the event activation.

I hope I was clear.
Thanks in advance to all readers
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"PeP" <io****@inwind.it> wrote in message news:<4J*********************@twister2.libero.it>. ..
Good morning,
I have a form containing a text-area,
I'd like to know if it exists a function that, when I activate an event,
returns the position of the cursor in the text-area.

For example, I write ten words in the text-area,
then I move the cursor at the beginning of the second word
and activate the event (for example, click on a button):
is there a way to know that the cursor is at the beginning of the second
word?

I know that the text-area is considered as a string,
so I want the position of the cursor in that string
at the moment of the event activation.


Having just had to do this for an intranet page where we wanted
to be able to click on terms in a list and have them insert into
a textarea at the cursor position (for an internal wiki), I can
tell you that it is possible, but only in IE unless you replace
the textarea with a _Java_ based editor.

See http://www.faqts.com/knowledge_base/...d/1052/fid/130
for a starting point. The IE code appears to be based on Microsoft's
own code at http://msdn.microsoft.com/library/de...am12032001.asp
(see "O Cursor Where art thou?")

This works, but it's not very nice or easy.
Jul 23 '05 #2

P: n/a
PeP
"MikeT" <ne**@chthonic.f9.co.uk> ha scritto nel messaggio
news:af**************************@posting.google.c om...
"PeP" <io****@inwind.it> wrote in message news:<4J*********************@twister2.libero.it>. ..
Good morning,
I have a form containing a text-area,
I'd like to know if it exists a function that, when I activate an event,
returns the position of the cursor in the text-area.

For example, I write ten words in the text-area,
then I move the cursor at the beginning of the second word
and activate the event (for example, click on a button):
is there a way to know that the cursor is at the beginning of the second
word?

I know that the text-area is considered as a string,
so I want the position of the cursor in that string
at the moment of the event activation.


Having just had to do this for an intranet page where we wanted
to be able to click on terms in a list and have them insert into
a textarea at the cursor position (for an internal wiki), I can
tell you that it is possible, but only in IE unless you replace
the textarea with a _Java_ based editor.

See http://www.faqts.com/knowledge_base/...d/1052/fid/130
for a starting point. The IE code appears to be based on Microsoft's
own code at

http://msdn.microsoft.com/library/de...us/dnwebteam/h
tml/webteam12032001.asp (see "O Cursor Where art thou?")

This works, but it's not very nice or easy.


Thank you Mike, I'm afraid I posted a FAQ (since 1998) and I'm sorry
in fact I found the same solutions you provide, doing a simple search with
Google.
Anyway I appreciate your attention and suggestion

Best regards
Jul 23 '05 #3

P: n/a
PeP
[cut]
For example, I write ten words in the text-area,
then I move the cursor at the beginning of the second word
and activate the event (for example, click on a button):
is there a way to know that the cursor is at the beginning of the second
word?

I know that the text-area is considered as a string,
so I want the position of the cursor in that string
at the moment of the event activation.

Having just had to do this for an intranet page where we wanted
to be able to click on terms in a list and have them insert into
a textarea at the cursor position (for an internal wiki), I can
tell you that it is possible, but only in IE unless you replace
the textarea with a _Java_ based editor.

See http://www.faqts.com/knowledge_base/...d/1052/fid/130
for a starting point. The IE code appears to be based on Microsoft's
own code at

http://msdn.microsoft.com/library/de...us/dnwebteam/h
tml/webteam12032001.asp (see "O Cursor Where art thou?")

This works, but it's not very nice or easy.


I found this
http://www.faqts.com/knowledge_base/...html/aid/13562
to be better than your first suggested link.
Bye
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.