Phil_at _work
09-05-2002, 01:27 AM
OK the Key Launcher works in IE but not inside of Netscape. It stopped working when I added to the code,
The below code was written so that I could include a Form in the the same page that I had included the Key Launcher this way when the user hits a defined key it doesn't navigate away if a defined key is pressed.
Problem is the key launcher doesn't work in Netscape now. I adopted the Key Launcher from another site and added the check to see if you are in a form.
JavaScript Error:
event is not defined.
-----------------------------CODE SNIP------------------------------
function checkKey(keypress)
{
var sourceTag;
var key = new Array();
sourceTag=event.srcElement.tagName;
if(sourceTag=="INPUT"||sourceTag=="TEXTAREA"||sourceTag=="OPTION")
{
}else{
key['c'] = "#content";
key['n'] = "#main_nav";
key['s'] = "#section_nav";
key['t'] = "index.htm";
key['h'] = "help.htm";
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for
(var i in key) if (which == i) window.location = key[i];
}
}
document.onkeypress = checkKey;
-----------------------------CODE SNIP------------------------------
Thanks in advance.
Phil
The below code was written so that I could include a Form in the the same page that I had included the Key Launcher this way when the user hits a defined key it doesn't navigate away if a defined key is pressed.
Problem is the key launcher doesn't work in Netscape now. I adopted the Key Launcher from another site and added the check to see if you are in a form.
JavaScript Error:
event is not defined.
-----------------------------CODE SNIP------------------------------
function checkKey(keypress)
{
var sourceTag;
var key = new Array();
sourceTag=event.srcElement.tagName;
if(sourceTag=="INPUT"||sourceTag=="TEXTAREA"||sourceTag=="OPTION")
{
}else{
key['c'] = "#content";
key['n'] = "#main_nav";
key['s'] = "#section_nav";
key['t'] = "index.htm";
key['h'] = "help.htm";
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for
(var i in key) if (which == i) window.location = key[i];
}
}
document.onkeypress = checkKey;
-----------------------------CODE SNIP------------------------------
Thanks in advance.
Phil