Dear newsgroup,
I am dealing with little problem. I am trying to figure out how to
delete and (replace) text, which user selected, on some given page.
Firsly I had been using content.document.getSelection() but it only
returned raw text, nor any node or range. So I've come to use this
piece of code:

var range = window.getSelection().getRangeAt(0); <-- this throws an

But 1st line of code throws and exception which can be seen in Error

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsISelection.getRangeAt]"
nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS
frame :: chrome://fireaccent/content/fireaccent.js :: doXPCOM :: line
28" data: no]

It doesn't depend if user selected some text or not, exception is
thrown allways...

Does anybody know how to solve it?

Thank you,
Tomas Vymazal

PS: I am using Firefox 3.5 with separated development profile only
with Venkmann extension installed...