views:

159

answers:

1

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?

+2  A: 

The window object you are using in the getSelection funtion is the browser's window, not the document's window. You probably need to use content instead:

function getSelected() {
    var sel = content.getSelection();
    alert(sel);
}

Check this resources for more info:

amercader