I'm trying to disable F11 key press in my application.
Previously i was using the below code to throw a JavaScript alert when user hits F11 key.
if (e.keyCode == 122 && e.type == "keydown") { alert ("F11 is not currently supported by this application.") e.keyCode = false; e.cancelBubble = true; e.returnValue = false; return false; }
The above code works fine when i was using IE6.
When i start using IE8, it did not work. I tried to use e.preventDefault() inside the above if loop, but it did not work as expected in IE8.
Still the Browser goes into Full Screen Mode (which i don't want to do)
@sneff - Thanks for the suggestions. But restricting the F11 key is the ask from the team. Previously we were able to suppress in IE6. But the same code doesn't work.
What @Senff was hinting at is that it is not acceptable for a site to impose those types of restrictions on a user's OS. Modern browsers are designed to actively prevent it, and they should - it's a security risk.
You should be looking for a different solution to whatever problem you're trying to address.
Try using JavaScript to detect when the viewable browser size reaches the same size (within a few pixels) as the actual screen size. Then you could throw up your alert to tell the user to exit full screen mode.
I actually meant "a different solution" to the larger problem (if there is one), i.e., whatever it is that goes wrong in fullscreen mode -- not just some other way to try to take over the user's preferences.
I'm trying to disable F11 key press in my application.
Previously i was using the below code to throw a JavaScript alert when user hits F11 key.
The above code works fine when i was using IE6.
When i start using IE8, it did not work.
I tried to use e.preventDefault() inside the above if loop, but it did not work as expected in IE8.
Still the Browser goes into Full Screen Mode (which i don't want to do)
Please provide your valuable thoughts.
Thanks!!!
Anyone Please provide some solution on the same.
You should be looking for a different solution to whatever problem you're trying to address.