WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
4609
window.getSelection().toString() is undefined (range object returned from window.getSelection() is useless)
https://bugs.webkit.org/show_bug.cgi?id=4609
Summary
window.getSelection().toString() is undefined (range object returned from win...
Berndt Jung
Reported
2005-08-23 17:40:43 PDT
This should get the text of the selection's start container. The mozilla version works, and the Safari version used to work (old safari). The two examples below are meant as bookmarklets. Safari will report that the returned object is a range object, but I cannot do anything with this object, such as get the start/ end containers/offsets. Interestingly toString() does not work either, yet if it is concatinated with a string, it does work. safari: <a href="javascript:d=window.getSelection();alert(d.startContainer.data);">getStartContainerText() </a> mozilla: <a href="javascript:d=window.getSelection().getRangeAt(0);alert (d.startContainer.data);">getStartContainerText()</a>
Attachments
test cases
(1.17 KB, text/html)
2005-08-23 17:45 PDT
,
Berndt Jung
no flags
Details
test case
(608 bytes, text/html)
2005-12-24 05:09 PST
,
Alexey Proskuryakov
no flags
Details
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Berndt Jung
Comment 1
2005-08-23 17:45:36 PDT
Created
attachment 3542
[details]
test cases Drag the links to the bookmark bar to test
Oliver Hunt
Comment 2
2005-09-07 04:29:36 PDT
Nice test case, although interestingly ffx seems to be able to do both mozilla+safari mechanisms for at least one test
Alexey Proskuryakov
Comment 3
2005-12-24 04:28:10 PST
Actually, window.getSelection() does not return a Range object - it returns a Selection object (with type None, Caret or Range), which doesn't have startContainer <
http://developer.mozilla.org/en/docs/
DOM:Selection>. The patch in
bug 4904
adds support for getRangeAt, so the "Mozilla" way starts to work. Keeping this bug to track the problem with toString().
Alexey Proskuryakov
Comment 4
2005-12-24 05:09:19 PST
Created
attachment 5259
[details]
test case
Justin Garcia
Comment 5
2006-01-03 15:05:13 PST
Landing the toString fix. Turns out it was defined as a method on our JS Selection object, but we didn't handle it in Selection::callAsFunction getRangeAt and toString should now behave like they do in FF.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug