I'd like to do something pretty basic in a browser extension that
involves getting information that is highlighted - how can I evaluate
what is highlighted in the browser? Thanks for your help with this
basic question.
document.getSelection() is deprecated. For the line above, use:
var winWrapper = new XPCNativeWrapper(focusedWindow, "window", "getSelection()");
> var string = winWrapper.getSelection().toString();
--
Soyapi Mumba
soyapi.blogspot.com
> See window.getSelection here:
> http://developer.mozilla.org/en/docs/DOM:window.getSelection
I have just been trying to implement this in Firefox 2. If I have a
button on my toolbar that calls this:
selObj = window.getSelection();
window.alert(selObj);
I just get an empty alert. (This is copied straight from the MDC page
Dom:selection.)
I have looked through DomInspector to see if there is another window
object that I should be using, but using other window objects that I
found like this:
document.getElementById('content').selectedBrowser.focusedWindow.getSelection()
...doesn't work either.
Can anyone tell me how to do this in Firefox?
Cheers
M
--
Matthew Smith
IT Consultancy & Web Application Development
Business: http://www.kbc.net.au/
Personal: http://www.smiffysplace.com/
LinkedIn: http://www.linkedin.com/in/smiffy
>A recent thread talked about working with selected text:
>
>>>I'd like to do something pretty basic in a browser extension that involves getting information that is highlighted - how can I evaluate what is highlighted in the browser? Thanks for your help with this basic question.
>>>
>>>
>>See window.getSelection here:
>>http://developer.mozilla.org/en/docs/DOM:window.getSelection
>>
>>
>I have just been trying to implement this in Firefox 2. If I have a button on my toolbar that calls this:
>
>selObj = window.getSelection();
>window.alert(selObj);
>
>I just get an empty alert.
>
content.getSelection() probably suffices in your case.
--
Warning: May contain traces of nuts.