the javascript file contains this code:
function getSelected(win) {
sel = win.getSelection();
alert(sel);
}
The browser.xul file contains this:
<popup id="contentAreaContextMenu">
<menuitem id="selection" label="Select text" accesskey="S"
oncommand="getSelected(window);"/>
</popup>
The alert is blank, why?
The window object you are using in the getSelection function is the browser’s window, not the document’s window. You probably need to use
contentinstead:Check this resources for more info: