Shift-click: Disabling
Question: Can I disable the default browser response for Shift-click event?
Answer: In Netscape Navigator 4 or
Internet Explorer 4 or newer browsers,
you can distinguish the Shift-click event from a simple click,
and disable the default response for Shift-click.
For example, Shift-click has been disabled on this page.
If you use version 4 browser (or newer) under Windows,
shift-click on any hyperlink on this page to test that!
(In older browsers, you would still get the default response.)
To disable Shift-click, insert the following
code in your page's <HEAD>
section:
<script language="JavaScript">
<!--
function mouseDown(e) {
var shiftPressed=0;
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape")
shiftPressed=(e.modifiers-0>3);
else shiftPressed=event.shiftKey;
if (shiftPressed) {
alert ('Shift-click is disabled.')
return false;
}
}
return true;
}
if (parseInt(navigator.appVersion)>3) {
document.onmousedown = mouseDown;
if (navigator.appName=="Netscape")
document.captureEvents(Event.MOUSEDOWN);
}
//-->
<script>
JavaScripter.net.
Copyright
© 1999-2006, Alexei Kourbatov