Results 1 to 1 of 1

Thread: Disable browser F1 and replace with own content

  1. #1
    Join Date
    Aug 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Disable browser F1 and replace with own content

    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
    
    }
    Last edited by redphill; 08-27-2009 at 12:43 PM. Reason: added url

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •