window.getSelection() does not work in my extension

1,717 views
Skip to first unread message

khalil dureidy

unread,
Apr 9, 2011, 6:59:33 PM4/9/11
to Chromium-extensions
I use in my extension a javascript function window.getSelection() to
get a selected text in an open chrome tab, but it always return empty
String
what should I do to make it work?

Thanks,
Khalil.

Arne Roomann-Kurrik

unread,
Apr 11, 2011, 1:51:49 PM4/11/11
to khalil dureidy, Chromium-extensions
It's really hard to speculate what you might be doing wrong without seeing any code.  So instead of telling you what you need to change, here's a sample extension which grabs the selection from the current page and renders it in a popup:


You might be able to figure out what to do from looking at that code.

~Arne



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


arthur

unread,
Apr 11, 2011, 3:06:54 PM4/11/11
to kur...@chromium.org, khalil dureidy, Chromium-extensions
FYI. With my limited experience, Chrome Extension content script can't
get selection from iframe (e.g. Gmail/Gdoc)

http://code.google.com/p/chromium/issues/detail?id=65636

http://groups.google.com/a/chromium.org/group/chromium-extensions/browse_thread/thread/a955986561a861c0?hl=en#

I didn't get much input and didn't test newer versions of Chrome after that.

Arthur


On 11/04/2011 1:51 PM, Arne Roomann-Kurrik wrote:
> It's really hard to speculate what you might be doing wrong without
> seeing any code. So instead of telling you what you need to change,
> here's a sample extension which grabs the selection from the current
> page and renders it in a popup:
>
> https://github.com/kurrik/chrome-extensions/tree/master/contentscript-selection
>
> You might be able to figure out what to do from looking at that code.
>

> <https://github.com/kurrik/chrome-extensions/tree/master/contentscript-selection>~Arne


>
>
> On Sat, Apr 9, 2011 at 3:59 PM, khalil dureidy <kdur...@gmail.com
> <mailto:kdur...@gmail.com>> wrote:
>
> I use in my extension a javascript function window.getSelection() to
> get a selected text in an open chrome tab, but it always return empty
> String
> what should I do to make it work?
>
> Thanks,
> Khalil.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Chromium-extensions" group.
> To post to this group, send email to
> chromium-...@chromium.org

> <mailto:chromium-...@chromium.org>.


> To unsubscribe from this group, send email to
> chromium-extens...@chromium.org

> <mailto:chromium-extensions%2Bunsu...@chromium.org>.

Reply all
Reply to author
Forward
0 new messages