Bug 71451 - textarea.caretPos and selectionStart / selectionEnd not implemented
Summary: textarea.caretPos and selectionStart / selectionEnd not implemented
Alias: None
Product: konqueror
Classification: Applications
Component: khtml ecma (show other bugs)
Version: 3.2-beta
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konqueror Developers
Depends on:
Reported: 2003-12-29 21:45 UTC by Vedran Ljubovic
Modified: 2006-03-26 05:23 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:

Testcase (1.36 KB, text/html)
2005-03-08 06:01 UTC, Sean Lynch
detection of possible methods (666 bytes, text/html)
2005-11-18 14:45 UTC, Anton

Note You need to log in before you can comment on or make changes to this bug.
Description Vedran Ljubovic 2003-12-29 21:45:48 UTC
Version:           konqueror/kjs (using KDE 0)
Compiler:          Linux
OS:          Continue

There is an undocumented IE property of textarea named caretPos which gives the current cursor position within that textarea. It shouldn't be confused by caretPos used by the caret mode (more info in bug #48302). Googling for this property I couldn't find any reference apart from a few forum and mailing list postings such as this one:


It is used by some forum softwares, such as the extremely popular PhpBB, for inserting emoticons and enclosing selected text with BB tags. Without it, emoticons are appended instead of inserted at the cursor position.

Meanwhile, Mozilla for this purpose uses selectionStart and selectionEnd properties. See this Bugzilla entry for reference:
This is also unavailable in Konqueror.

Having no way to determine cursor position in textarea is a big obstacle for web developers.
Comment 1 Bonnaud Frédéric 2004-11-10 16:30:18 UTC
I think it'd be better to support gecko's behaviour
Comment 2 Xavier Spirlet 2005-01-24 16:42:47 UTC
I agree with Frédéric. Best thing is to support standards. IE's way works, but is quite complicated and nonstandard. I'd rather see getSeletion(), selectionStart and selectionEnd methods implemented. They are in Mozilla and Firefox... Please, please, please, it's so frustrating not to be able to manipulate texte inside <textarea>'s ;o)
Comment 3 Sean Lynch 2005-03-08 06:01:09 UTC
Created attachment 10018 [details]

I would very much like to see this implemented.  Currently there is no way to
manipulate text data, which is really hampering me with a current page I'm
working on (which includes a phpbb-type syntax writer with javascript buttons
for bold/italic/underline/font color/etc).

I wrote a testcase for the 3 functions I need implemented.. 

selectionStart (where the beginning of the selection starts... equals cursor
position if no selection is made)

selectionEnd (where the end of the selection ends... equals cursor position if
no selection is made)

textLength (total characters typed in field)

The testcase is separated into a <textarea> and <input type="text"> with
textboxes representing the appropriate info.  The textbox is set to update the
textboxes onKeyPress, but the <input type="text"> requires the Update button to
be pressed.
Comment 4 Anton 2005-11-18 14:45:01 UTC
Created attachment 13535 [details]
detection of possible methods

Agree with all you guys.
I was googling around and didn't find any standart for it.
Attached the test case detecting if method supported by browser.

We really need a way to get current possition of cursor in the text fields.
Comment 5 Maksim Orlovich 2006-01-28 21:57:42 UTC
SVN commit 503345 by orlovich:

-Implement selectionStart, selectionEnd, and textLength on textarea
-Fix the value on physical wrapped mode to not invent spaces
-Proper changed check on updateFromElement, so we don't reset the textarea
Among other things, makes phpBB editting buttons work.

 M  +34 -0     dom/html_form.cpp  
 M  +39 -1     dom/html_form.h  
 M  +8 -0      ecma/kjs_html.cpp  
 M  +2 -1      ecma/kjs_html.h  
 M  +54 -1     html/html_formimpl.cpp  
 M  +6 -0      html/html_formimpl.h  
 M  +138 -2    rendering/render_form.cpp  
 M  +16 -0     rendering/render_form.h  
Comment 6 Sean Lynch 2006-03-26 05:22:47 UTC
textLength looks to still be unsupported in 3.5.2... anyway to get that added (see my testcase above)
Comment 7 Sean Lynch 2006-03-26 05:23:38 UTC
Meant to say for <input type='text'> that is, its working for textareas.