Created
January 5, 2011 14:04
-
-
Save cou929/766350 to your computer and use it in GitHub Desktop.
Sample code for form history auto complete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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