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: https://lists.latech.edu/pipermail/javascript/2003-June/005872.html 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: http://bugzilla.mozilla.org/show_bug.cgi?id=88049 This is also unavailable in Konqueror. Having no way to determine cursor position in textarea is a big obstacle for web developers.
I think it'd be better to support gecko's behaviour
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)
Created attachment 10018 [details] Testcase 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.
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.
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 willy-nilly Among other things, makes phpBB editting buttons work. BUG:71451 BUG:79371 BUG:113217 BUG:109092 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
textLength looks to still be unsupported in 3.5.2... anyway to get that added (see my testcase above)
Meant to say for <input type='text'> that is, its working for textareas.