//Set the handler to the redefined keys routine document.onkeyup = handleKeyUp; // Redefine function key for the special key F1 (help) window.onhelp = display_help; // Redefine keys for Internet Explorer function handleKeyUp(e) { if(!e) { var e = window.event; mozilla_handler = false; } else { mozilla_handler = true; } var key = e.keyCode; if (112==key) // && (navigator.platform=="MacPPC") { // F1 key, do something then cancel display_help(); return cancel(); } else if (1234==key) // 123==key for real F12 detection { // F12 key, do something then cancel alert('F12 key, congratulation!'); return cancel(); } // Inline cancel function function cancel() { e.cancelBubble=true; if (!mozilla_handler) { e.keyCode=0; } return false } return true; } // Help display function function display_help(p1) { page_name = location.href.substr(1+location.href.lastIndexOf('/')).replace('#',''); pos_param = page_name.lastIndexOf('?'); if (pos_param > 0) { page_name = page_name.substr(0,pos_param); } if (p1) { item_name = p1; // alert('Help page for '+p1+' on page ' + page_name); } else { item_name = ''; // alert('Help page for page '+page_name); } return false; } function getRandomNum(lbound, ubound) { return (Math.floor(Math.random() * (ubound - lbound)) + lbound); } function getRandomChar(number, lower, upper, other, extra) { var numberChars = "0123456789"; var lowerChars = "abcdefghijklmnopqrstuvwxyz"; var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? "; var charSet = extra; if (number == true) charSet += numberChars; if (lower == true) charSet += lowerChars; if (upper == true) charSet += upperChars; if (other == true) charSet += otherChars; return charSet.charAt(getRandomNum(0, charSet.length)); } function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther, latterNumber, latterLower, latterUpper, latterOther) { var rc = ""; if (length > 0) rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars); for (var idx = 1; idx < length; ++idx) { rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars); } return rc; }