0
我正在創建一個Firefox擴展。在擴展的js文件存在一定條件後,我必須重新啓動Firefox。 那麼如何通過擴展名javascript重新啓動Firefox瀏覽器? 在此先感謝。如何從Firefox擴展重新啓動Mozila Firefox瀏覽器
我正在創建一個Firefox擴展。在擴展的js文件存在一定條件後,我必須重新啓動Firefox。 那麼如何通過擴展名javascript重新啓動Firefox瀏覽器? 在此先感謝。如何從Firefox擴展重新啓動Mozila Firefox瀏覽器
使用this code:
function restart() {
let canceled = Cc["@mozilla.org/supports-PRBool;1"]
.createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(canceled, "quit-application-requested", "restart");
if (canceled.data) return false; // somebody canceled our quit request
// disable fastload cache?
if (getPref("disable_fastload")) Services.appinfo.invalidateCachesOnRestart();
// restart
Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup)
.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
return true;
}
以下將調用已有的Mozilla重新啓動命令(其可以確保所有適當的清理工作)。
這會從那裏您可以訪問瀏覽器窗口元素的環境中工作(從你打開一個對話框,即(如選項對話框)):
window.opener.content.document.getElementById('cmd_restartApp').doCommand();
如何從瀏覽器的命令行做安慰? – Noitidart 2014-09-30 14:16:49