Comments on: getSelection() returns empty in Google Mail http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/ Code and comments on web development, Django, Python and things (un)related. Wed, 03 Apr 2013 13:15:20 +0000 hourly 1 http://wordpress.org/?v=4.3 By: jason braswell http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/comment-page-1/#comment-1055 Thu, 11 Aug 2011 15:33:28 +0000 http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comment-1055 Thanks! This saved a newbie (me) a lot of time.

]]>
By: Natch http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/comment-page-1/#comment-797 Tue, 15 Jun 2010 19:56:40 +0000 http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comment-797 top.document.activeElement.contentWindow.getSelection();

For some odd reason the activeElement is always an HTML Iframe element. This works for me in Gmail.

G’luck.

]]>
By: Fraser http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/comment-page-1/#comment-779 Tue, 16 Mar 2010 23:37:50 +0000 http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comment-779 Hi – I ran into the same problem in gmail with getSelection(). I think that it may be because gmail uses several frames – if you iterate over window.frames and call getSelection() on each one, you may find what you’re looking for.

]]>
By: Scott http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/comment-page-1/#comment-647 Fri, 20 Mar 2009 03:21:39 +0000 http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comment-647 Hi Lenny.

You can call window.content.getSelection() in a bookmarklet, but of course that won’t work in Gmail. It looks like document.commandDispatcher is only available within XUL (e.g. a Firefox extension), not for regular JavaScript in a web page or bookmarklet.

Sorry, I don’t know of a workaround.

]]>
By: Lenny http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/comment-page-1/#comment-646 Thu, 19 Mar 2009 23:05:16 +0000 http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comment-646 Hi Scott, I’m not sure how to use this solution in a bookmarklet.
Is that possible?

]]>
By: Bernard http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/comment-page-1/#comment-584 Wed, 19 Nov 2008 21:42:10 +0000 http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comment-584 Any ideas how to get selected text from gmail in Chrome?

]]>
By: Gavin http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/comment-page-1/#comment-554 Sat, 27 Sep 2008 21:14:58 +0000 http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comment-554 Thanks for this info. Exactly my problem, and solution!

Gavin

]]>
By: Craig Williams http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/comment-page-1/#comment-426 Tue, 09 Sep 2008 06:11:47 +0000 http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comment-426 Hey Scott,

Thanks for posting this!
It is coming in very handy.

]]>