document.onkeydown = function(e) {
console.log(e);
if (e.keyCode == 116 || (e.ctrlKey && e.keyCode == 82)) {
console.log("avoid reload");
return false;
}
}
Archiv der Kategorie: development
Javascript Auto Suggest
Searching for a simple auto suggest input field, I found:
http://www.javascriptsearch.com/tutorials/Advanced/tutorials/AUTOSUGGEST1.html
http://www.javascriptsearch.com/tutorials/Advanced/tutorials/AUTOSUGGEST2-1.html
Minor improvements added, results to download:
The Auto Suggest Controller can be used:
<script type="text/javascript">
var suggestControl;
window.onload = function () {
suggestControl = new AutoSuggestControl($TXT_FIELD_ID, new SuggestionProvider());
}
</script>
The AutoSuggestControl accepts a third optional parameter to configure the behaviour:
{typeAheadEnabled: $BOOLEAN, suggestDropDownEnabled: $BOOLEAN, minValueLength: $INTEGER
Each of this parameters is optional.
The default configuration:
typeAheadEnabled: false
suggestDropDownEnabled: true
minValueLength: 0
The AutoSuggest Controller to use
Base CSS
Base Data Provider to implement
US States Suggestion Provider
Test Provider with 15000 entries
Javascript Alert
if (tzu == undefined) {
var tzu = {};
}
tzu.alert = function(txt) {
txt = txt.replace(/Ü/g, "%DC");
txt = txt.replace(/ü/g, "%FC");
txt = txt.replace(/Ö/g, "%D6");
txt = txt.replace(/ö/g, "%F6");
txt = txt.replace(/Ä/g, "%C4");
txt = txt.replace(/ä/g, "%E4");
txt = txt.replace(/ß/g, "%DF");
txt = txt.replace(/n/g, "%0A");
alert(unescape(txt));
}