Safari for iPhone: window.getSelection(); in a bookmarklet does not work

Number:rdar://7013257 Date Originated:2009-06-27
Status:Duplicate Resolved:
Product:iPhone Product Version:3.0
Classification:Enhancement Reproducible:Always
When a JavaScript bookmarklet in Safari for iPhone 3.0 uses window.getSelection(), it does not work. The selection is removed as soon as the bookmarks menu is opened.

Steps to Reproduce:
1. Install a JavaScript bookmarklet that uses window.getSelection(), like the one here: or the "view selection" one here:
2. Open a web page
3. Select some text
4. Tap the bookmarks button
5. Select the bookmarklet

Expected Results:
The bookmarklet should be able to access the selected text.

Actual Results:
As soon as the bookmarks button is tapped, the selection is removed, so the script is unable to see what text was selected.





This is a duplicate of rdar://7024250

By robotspacer at Aug. 20, 2010, 10:26 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!