|
Mit diesem Script können Sie innerhalb einer Seite navigieren, wenn eine Taste des Alphabets gedrückt wird. Mit diesem Beispiel ist es auch möglich andere JavaScript-Funktionen zu starten. Den "Tastencode" entnehmen Sie aus der Tabelle ASCII, Sonderzeichen, Unicode, ...
Beispiel anzeigenQuelltext:
<script type="text/javascript">
document.onkeydown = Tastendruck;
function Tastendruck (Evenement) {
if (!Evenement)
Evenement = window.event;
if (Evenement.which) {
Tastencode = Evenement.which;
} else if (Evenement.keyCode) {
Tastencode = Evenement.keyCode;
}
taste(Tastencode);
}
function taste(Tastencode){
if (Tastencode == 65) {location.href="#a"}
if (Tastencode == 66) {location.href="#b"}
if (Tastencode == 67) {location.href="#c"}
if (Tastencode == 68) {location.href="#d"}
if (Tastencode == 69) {location.href="#e"}
if (Tastencode == 70) {location.href="#f"}
if (Tastencode == 71) {location.href="#g"}
if (Tastencode == 72) {location.href="#h"}
if (Tastencode == 73) {location.href="#i"}
if (Tastencode == 74) {location.href="#j"}
if (Tastencode == 75) {location.href="#k"}
if (Tastencode == 76) {location.href="#l"}
if (Tastencode == 77) {location.href="#m"}
if (Tastencode == 78) {location.href="#n"}
if (Tastencode == 79) {location.href="#o"}
if (Tastencode == 80) {location.href="#p"}
if (Tastencode == 81) {location.href="#q"}
if (Tastencode == 82) {location.href="#r"}
if (Tastencode == 83) {location.href="#s"}
if (Tastencode == 84) {location.href="#t"}
if (Tastencode == 85) {location.href="#u"}
if (Tastencode == 86) {location.href="#v"}
if (Tastencode == 87) {location.href="#w"}
if (Tastencode == 88) {location.href="#x"}
if (Tastencode == 89) {location.href="#y"}
if (Tastencode == 90) {location.href="#z"}
}
</script>
Zur Seitennavigation bitte eine Taste des Alphabets betätigen.
<h2><a name="a">A</a></h2>
Viel Text ...
<h2><a name="b">B</a></h2>
Viel Text ...
<h2><a name="c">C</a></h2>
Viel Text ...
<h2><a name="d">D</a></h2>
Viel Text ...
......................................................................................
<h2><a name="x">X</a></h2>
Viel Text ...
<h2><a name="y">Y</a></h2>
Viel Text ...
<h2><a name="z">Z</a></h2>
Viel Text ...
|
Das könnte Sie interessieren:
JavaScript Bausteine 2
Dynamisches Eingabefeld (3) - mit mehreren Auswahllisten
Fenstergröße und Fensterposition mit einem Link ändern
Radiobutton mit Auswahl-Hinweis
Drehregler mit Mausrad-Unterstützung
Ausgabe des aktuellen Datums - Dieses JS schreibt das aktuelle Datum auf eine Seite.
JS-Index - Objekteigenschaften
Seitennavigation mit Tasten
Internet Explorer-Erkennung in JavaScript - Prüfen ob vom Besucher der Internet Explorer verwendet wird.
Leerstellen löschen - Ist es bei der Eingabe in Textboxen sinnvoll, die Daten ohne Leerstellen zu versenden, eignet sich dieses Script hervorragend dafür.
Benutzereingaben mit JavaScript lokal speichern - HTML 5 bietet uns die Möglichkeit, mittels des localStorage oder sessionStorage einfache Daten im Client zu speichern.
…mehr