2014-11-08 53 views
1

我在我的browser.xul中使用了以下命令來爲我的插件設置快捷方式。Firefox附加快捷方式不起作用

<keyset id="mainKeyset"> 
    <key id="key_convert" 
     modifiers="accel" 
     keycode="VK_F12" 
     oncommand="myfunction()" />" 
</keyset> 

它曾經適用於以前版本的Firefox,但不再適用於新版本。 語法有什麼變化?

感謝

回答

-1

一些注意事項:

可以複製此粘貼到便箋:

var keyset = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'keyset'); //http://forums.mozillazine.org/viewtopic.php?f=19&t=2711165&p=12885299&hilit=mainKeyset#p12885299 
//cant use mainKeyset see topic above 
var key = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'key'); 
var props = { 
    id: 'key_convert', 
    modifiers: 'accel', 
    keycode: 'VK_F12', 
    oncommand: 'alert("tirggered")' 
}; 
for (var p in props) { 
    key.setAttribute(p, props[p]); 
} 
keyset.appendChild(key); 
Services.wm.getMostRecentWindow('navigator:browser').document.documentElement.appendChild(keyset); 
0

的示例代碼看起來是正確的,我懷疑有內myfunction()一些代碼失敗,所以我們可能需要更多的信息。嘗試替換myfunction()alert("test"),這應該工作。

相關問題