Skip to content

Instantly share code, notes, and snippets.

@cou929
Created January 5, 2011 14:04
Show Gist options
  • Save cou929/766350 to your computer and use it in GitHub Desktop.
Save cou929/766350 to your computer and use it in GitHub Desktop.
Sample code for form history auto complete
/*
* Kosei Moriyama <[email protected]>
*
* Sample code for Firefox Extensions.
* Enable auto complete for certain form from history of inputs.
*/
// Write like this in xul firstly.
// Set "id" and "autocompletesearchparam" attribute for your own.
// <textbox id="my-form" type="autocomplete" autocompletesearch="form-history" autocompletesearchparam="my-form-history"/>
// Then write like this in js file.
// replace "my-form" and "my-form-history" for your value
function addFormHistory() {
var entry = document.getElementById('my-form').value;
var formHistory = Components.classes["@mozilla.org/satchel/form-history;1"]
.getService(Components.interfaces.nsIFormHistory2 || Components.interfaces.nsIFormHistory);
formHistory.addEntry("my-form-history", entry);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment