1) CODE TITLE: Disable browser F1 and replace with own content (cross browser compatible)
2) AUTHOR NAME/NOTES: Phill Moore, Regent Internet (www.regentinternet.co.uk)
3) DESCRIPTION: For site specific help, particularly browser based applications - this script disables the standard browser help and allows you to do your own thing. Tested and works in FF 3.0.13, IE 7, Opera 9.63, Safari 3.2.2, Google Chrome 2. I use with DHTML Window Widget v1.1 from Dynamic Drive to bring up my own help box.
4) URL TO CODE:
URL to live example: http://www.regentinternet.co.uk/f1test/f1test.html
or, ATTACHED BELOW (see #3 in guidelines below):
Code:// disable MSIE standard help function document.onhelp = new Function("return false;"); window.onhelp = new Function("return false;"); document.focus; // get key stroke for Firefox, Opera, Google Chrome document.onkeypress = keyHit; // get key stroke for MSIE, Safari var browser=navigator.userAgent; if (browser.search(/msie|safari/i) != -1) document.onkeydown = keyHit; // keystroke handling function keyHit(event) { // get correct keycode depending on browser var keyStruck; if (browser.search(/msie|safari/i) != -1) keyStruck = window.event.keyCode; else keyStruck = event.keyCode; if (keyStruck == 112) { if (browser.search(/msie/i) == -1) { // disable browser standard help function for all but MSIE (see above for MSIE) event.stopPropagation(); event.preventDefault(); } keyAction('help'); // call routine to replace standard help function } // You can add the capture of other keystrokes here } // replacement help function function keyAction(action) { if (action == 'help') { // Your new help function goes here // I have used in conjunction with DHTML Window widget (v1.1) from Dynamic Drive to deliver a new help file } // You can add the actions for other keystrokes here }



Reply With Quote
Bookmarks