Solved

Disable Hot Keys in Internet Explorer

Posted on 2004-09-03
3
2,075 Views
Last Modified: 2008-01-09
I have a link which opens a new window.  The new window does not have the menu toolbar, standard buttons toolbar, and address toolbar.  I did this because I don't want the user to be able to refresh the page or hit the back button.  I had hoped eliminating these toolbars would prevent them from doing this.

However, the hot keys such as F5 (refresh) still work.

Can I disable the hot keys as well?

I read somewhere that you could do this in Netscape Navigator.  However, I am only interested in doing this in Internet Explorer.

I am primarily interested in the Refresh Hot Key, and the Back and Forward Hot Keys.  Maybe the Stop (Esc) Hot Key.

Thanks
0
Comment
Question by:FranzRinkleff
3 Comments
 
LVL 15

Expert Comment

by:justinbillig
ID: 11976965
use a modal dialog IE only

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodaldialog.asp

window.showModalDialog( )

// -------------------------------------------------------------------------
      //  Name: OpenModalDialog
      //  Abstract: Open the specified page in a modal window
      // -------------------------------------------------------------------------
      function OpenModalDialog( strPage, intHeight, intWidth, objDialogArguments )
      {
            var objResult = 0;
            try
            {
                  var strDialogOptions = "" +
                              "border=thin;" +
                              "center=yes;" +
                              "dialogHeight=" + intHeight + "px;" +
                              "dialogWidth=" + intWidth + "px;" +
                              "help=no;" +
                              "maximize=no;" +
                              "minimize=no;" +
                              "status=no;";
                  objResult = window.showModalDialog( strPage, objDialogArguments, strDialogOptions );
            }
            catch( expError )
            {
                  alert( "ClientUtilities1.js::OpenModalDialog( ).\n" +
                              "Error:" + expError.number + ", " + expError.description );
            }
            finally
            {
                  // Return result
                  return objResult;
            }
      } // OpenModalDialog


heres a function i wrote to open modal dialogs
0
 
LVL 32

Accepted Solution

by:
ldbkutty earned 250 total points
ID: 11976982
This is a code from mplungjan for disabling the 'function' keys:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20722410.html

<html>
<head>
     <title>Untitled</title>
</head>

<body>
<script>
keys = new Array();
keys["f112"] = 'f1';
keys["f113"] = 'f2';
keys["f114"] = 'f3';
keys["f115"] = 'f4';
keys["f116"] = 'f5';
keys["f117"] = 'f6';
keys["f118"] = 'f7';
keys["f119"] = 'f8';
keys["f120"] = 'f9';
keys["f121"] = 'f10';
keys["f122"] = 'f11';
keys["f123"] = 'f12';

saveCode=""
function myFunc(code) {
  alert('testing '+code)
}

document.onkeydown = function(){
 // Capture and remap F-key
  if(window.event && keys["f"+window.event.keyCode])  {
    saveCode=window.event.keyCode;
    window.event.keyCode = 505;
  }
  if(window.event && window.event.keyCode == 505) {
    // New action for keycode
    myFunc(saveCode)
    return false; // Must return false or the browser will execute old code
     }
}
</script>

</body>
</html>
0
 
LVL 1

Author Comment

by:FranzRinkleff
ID: 11977442
The link you provided from ldbkutty was just what I needed.  I also liked your example on how to disable the rest of the F keys.  

Thanks all,
Franz
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question