Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Using nsISimpleEnumerator

Using nsISimpleEnumerator

  • <stringbundle>.strings
var enumerator = document.getElementById('aStringBundleID').strings;
var s = "";
while (enumerator.hasMoreElements()) {
  var property = enumerator.getNext().QueryInterface(Components.interfaces.nsIPropertyElement);
  s += property.key + ' = ' + property.value + ';\n';
}
alert(s);

Example using JavaScript 1.7 features

// creates a generator iterating over enum's values
function generatorFromSimpleEnumerator(enum, interface) {
  while (enum.hasMoreElements()) {
    yield enum.getNext().QueryInterface(interface);
  }
}
var b = document.getElementById("stringbundleset").firstChild
var props = generatorFromEnumerator(b.strings, Components.interfaces.nsIPropertyElement);
var s = "";
for (let property in props) {
  s += property.key + ' = ' + property.value + ';\n';
}
alert(s);

Document Tags and Contributors

 Contributors to this page: teoli, Dolske, mcpherrinm, Ferric, Nickolay, Yanmorin
 Last updated by: Dolske,