Using getSelection() with content in frames
Sunday 12/28/2008 – Category: Uncategorized
An iPhoneSender user recently reported a bug with the Safari bookmarklet not correctly grabbing the selection and suspected it was because the selected content was in frames.
After some digging around, it turns out he was right--if your selection is in a frame, the normal window.getSelection() method will return nothing; you'll need to target the specific frame instead. We don't know the frame's name so we can't target it with parent.frames["framename"], but what we can do is just loop over all the frames in the document until we find it.
(simplified and expanded):
Leave a Reply
Recent Posts
- Marble Paint
(Friday 02/4/2011 – 1 Comment) - More Flickr Original Updates
(Sunday 01/23/2011 – 13 Comments) - Flickr Original updates
(Saturday 08/7/2010 – 19 Comments) - LED Light for iPhone 4
(Monday 06/28/2010 – 65 Comments)
