Solved

Disable Hot Keys in Internet Explorer

Posted on 2004-09-03
3
2,062 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now