Disable F1 effect (help) from browser using javascript

Posted in By waelouf 1 comments

This is a simple way to disable the default help in browser if you want to create your own help :)
Most of the code I "borrowed" from Dan Bartels' Blog and just make couple of modifications on it.

enjoy it

document.onhelp = new Function("return false;");
window.onhelp = new Function("return false;");
document.onkeydown = function (evt) {
if (evt == null) evt = event; if (testKeyCode(evt, 112)) //F1
cancelKeyEvent(evt); //don't allow default help popup by F1
alert(navigator.appName); alert("This is the new help");
return false;

function cancelKeyEvent(evt) {
if (window.createPopup) evt.keyCode = 0;
else evt.preventDefault();
function testKeyCode(evt, intKeyCode) {
if (window.createPopup) return evt.keyCode == intKeyCode;
else return evt.which == intKeyCode;