2011-02-16 91 views
2

如何正確從代碼重新啓動firefox(沒有任何「恢復會話」的事情,並與以前相同的窗口)?如何從代碼重新啓動Firefox?

我知道bash腳本過程中的「firefox-bin」的pid,並且我已將自定義插件加載到其中。

回答

3
Services.prefs.setBoolPref("browser.sessionstore.resume_session_once", true); 
const nsIAppStartup = Components.interfaces.nsIAppStartup; 
Components.classes["@mozilla.org/toolkit/app-startup;1"] 
      .getService(nsIAppStartup) 
      .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); 

請注意,這適用於Firefox 4,因此代碼可能與早期版本稍有不同。

+0

仍然在FF36中工作。 – zx81 2015-06-09 22:10:54