var selection = window.getSelection();
but, when I am trying to convert it using toString() or even print it
using:
alert(selection.toString());
I got only empty popup without any text.
When I tried to use Venkmann to debug this code, I've come to
conclusion that whole selection object I've got is empty (all members
are 0 or null).
Does anybody know how to deal with this?
Thank you for any information.
Tomas Vymazal
>I am dealing with little problem. I am trying to get (from my extension) user selected text from actual page. I am using recommended code:
>
>var selection = window.getSelection();
>
That's the browser's window, not the page's window. You probably want
content.getSelection(); see
https://developer.mozilla.org/en/Working_with_windows_in_chrome_code#Content_windows
--
Warning: May contain traces of nuts.
Many thanks!
This proved helpful. Now I am using this code to get selected text
from actual page:
var selObj = content.document.getSelection();
Everything works fine. Thank you again,
Tomas Vymazal