2010-01-10 65 views
0

JavaScript文件包含以下代碼:Firefox的插件,訪問選擇對象通過JavaScript

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

的browser.xul文件包含此:

<popup id="contentAreaContextMenu"> 
    <menuitem id="selection" label="Select text" accesskey="S" 
    oncommand="getSelected(window);"/> 
</popup> 

警報是空白的,爲什麼呢?

+0

getSelection函數是什麼樣的? – 2010-01-10 10:02:25

+0

@Jimmy Shelter,這個功能屬於窗口對象... – ronik 2010-01-10 10:08:41

回答