ok this is a piece of code I found...
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
this script captures key strokes and redirects accordingly...and it works fine but I was just wondering if anyone could explain the bold line. according to refrence book '?:' is called a ternary operator...but in true refrence book fashion there is no explaination to the things you dont understand. i think it is just a complex browser check and uses keystroke.which for netscape and event.keycode for ie, but does anyone know for sure? -Greg :-Q
Code:
var key = new Array();
key['c'] = "content/load/load_database.jsp";
key['o'] = "content/load/load_options.jsp";
key['e'] = "javascript:window.close()";
function getKey(keyStroke) {
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
Code:
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key) if (which == i) window.location = key[i];
}
document.onkeypress = getKey;
this script captures key strokes and redirects accordingly...and it works fine but I was just wondering if anyone could explain the bold line. according to refrence book '?:' is called a ternary operator...but in true refrence book fashion there is no explaination to the things you dont understand. i think it is just a complex browser check and uses keystroke.which for netscape and event.keycode for ie, but does anyone know for sure? -Greg :-Q