Javascript 如何存储首选项?

Javascript 如何存储首选项?,javascript,firefox,preferences,Javascript,Firefox,Preferences,我有这样的偏好: <!DOCTYPE overlay SYSTEM "chrome://inlinetrans/locale/options.dtd"> <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="translate-preferences" title="&options.title;" buttons="accept, cancel"

我有这样的偏好:

<!DOCTYPE overlay SYSTEM "chrome://inlinetrans/locale/options.dtd">

<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  id="translate-preferences"
  title="&options.title;"
  buttons="accept, cancel"
  style="padding:0px; margin:0px;"
  ondialogaccept="options.save()"
  onload="options.init();"
  onunload="options.deconstruct();">

  <script src="chrome://inlinetrans/content/options.js" />

  <description value="&options.desc;"
    style="
    background: #fff url('chrome://inlinetrans/skin/options.png') no-repeat;
    min-width:400px;
    min-height:40px;
    padding-left:55px;
    padding-top:10px;
    margin:0px;
    border-bottom: 2px solid #757575;
    font-size:1.5em;"/>

  <vbox style="padding:10px;">
    <groupbox>
      <caption label="&options.ui;"/>
      <label value="&options.results.desc;"/>
    <radiogroup id="display.results" style="padding-left:20px;">
      <radio id="results.cat" value="currenttab" label="&options.results.cat;"/>
          <radio id="results.noncat"  value="newwindow" label="&options.results.noncat;"/>
      </radiogroup>
    </groupbox>
 </vbox>
</dialog>

非常感谢您的帮助

我在存储首选项的值时遇到问题,您能帮我解决吗?@user495688:“我在存储首选项的值时遇到问题”-我们知道,这是您第一次说的。我们读过,但不明白。请用不同的词来描述你的问题是什么。我已经编辑了我的问题
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
var t_prefBranch = prefService.getBranch("extensions.inlinetrans.");

var options = {

  result : String,

  init : function() {
    this.updatePrefs()
    t_prefBranch.setCharPref("optionopen", true)

    var Displayresults = document.getElementById("results." + this.result)
        Displayresults.setAttribute("selected", true);
  },

  updatePrefs : function() {

    this.result = t_prefBranch.getCharPref("results")

  },

  save : function() {
    var savepref = document.getElementById("display.results").value

    if (savepref != "") {
        t_prefBranch.setCharPref("results", savepref)
    }

},

reloadOptions : function() {
  this.save()
  this.init()
}

}