I am using the following code for disabling Ctrl-N in IE7. It disables the Ctrl-N feature of IE which opens a new window containing the same page as the 'active' window. The code works great (at first glance). However, I noticed that, if you click anywhere inside the browser window and THEN press Ctrl-N, the new window will open. If you don't click anywhere inside the window, the following code works. Can anyone see an improvement to the following code so that clicking inside the browser window doesn't bypass the javascript?

<BODY>
<Script>
document.onkeydown=checkKeys
function checkKeys()
{
if (event.ctrlKey && event.keyCode==78)
{
  event.keyCode=0;
  return false;
}

}
</script>
</BODY>
</HTML>

Recommended Answers

All 2 Replies

Well, my first question would be why disable CTRL+N? That still leaves CTRL+T (new tab in ie7) and it doesn't prevent them from just opening a new instance of IE7 the normal way. I personally despise when people alter my keyboard shortcuts and/or disable things on a site. If you're doing this it usually means you've designed something wrong previously and you're trying to make up for it.

I'm Running my Application in kiosk mode. If the user press CTRL+N it is opening in a new browser window which is in non-kiosk more. So I want to prevent it.

Thanking You.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.