Ever have one of those really long alphabetical lists that neither you (or your user) wants to have to scroll thru but didnt want to put an obnoxious clickable alphabet at the top of the page?
I have. And with a bit of research and experimentation I came up with what I believe is an eloquent solution, using onKeyPress where the user simply types the first letter to quickly navigate to that part of the page (if they type "a" they are taken to anchor "A"):
-----------------------------------------------------------
<HTML><HEAD>
<TITLE>jsLove's Alpha Finder --- 08-21-2001</TITLE>
[color red]<SCRIPT language="JavaScript">
<!--
function handler(e) {
if (document.all) {e = window.event;}[/red] // IE
[color red]var key;
if (document.layers) key = e.which;[/red] // Netscape
[color red]if (document.all)key = e.keyCode;[/red] // IE
// converts key to lowercase since my anchors are all lowercase:
[color red]var chr = String.fromCharCode(key).toLowerCase();[/red]
// activates the anchor-- change the url to your page, but leave the #"+chr; :
[color red]window.location="http://www.yourpage.htm#"+chr;
}[/red]
// grabs the key and sends it to the handler function above:
[color red]document.onkeypress = handler;
//-->
</SCRIPT>[/red]
</HEAD>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.