Closed Bug 188495 Opened 22 years ago Closed 22 years ago

could not get a selection object from a input or textarea element

Categories

(Core :: DOM: Core & HTML, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: cunha, Assigned: jst)

Details

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 You can't get a selection object from a selected text inside a input or textarea element, only from a selection outside these elements. Reproducible: Always Steps to Reproduce: 1. Select any text inside a input(text) or textarea element 2. When you try to execute the following javascript code the selection object returned is empty(no range objects): sel = window.getSelection(); 3. Maybe it's because you can select a text outside the input or textarea element AND AT THE SAME PAGE select a text inside the element. 4. Javascript reports only the selection outside the element, never the inside one. Actual Results: yes Expected Results: return the selection object that represents the selected text inside the input or textarea element.
kin, didn't you guys fix this recently?
Summary: could not get a selection object from a input or textbox element → could not get a selection object from a input or textbox element
Summary: could not get a selection object from a input or textbox element → could not get a selection object from a input or textarea element
The fix bzbarsky is referring to is in bug 88049. The selection inside a text widget is different from the window/document selection. To access it, use |selectionStart| and |selectionEnd|: var selStart = myTextArea.selectionStart; var selEnd = myTextArea.SelectionEnd; Both |selectionStart| and |selectionEnd| are offsets between the characters in the text widget, so if you had a text widget that contained the string "abcd", and you wanted to select "bc" you would use: myTextArea.selectionStart = 1; myTextArea.selectionEnd = 3; or use: myTextArea.setSelectionRange(1,3);
So... is this bug valid?
Yeah, it's invalid.
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.