i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disable shift + mouse right click javascript
11-25-2011, 10:00 AM
Post: #1
Disable shift + mouse right click javascript
here is the code to disable mouse right click with the combination of shift
Code:
<html>
<head>
&lt;script language=JavaScript>
&lt;!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Function Disabled!";

///////////////////////////////////

function mouseDown(e) {
var shiftPressed=0;
var evt = e?e:window.event;
if (parseInt(navigator.appVersion)>3) {
  if (document.layers && navigator.appName=="Netscape")
       shiftPressed=(evt.modifiers-0>3);
  else shiftPressed=evt.shiftKey;
  if (shiftPressed) {
   alert ('Shift-click is disabled.')
   return false;
  }
}
return true;
}
if (parseInt(navigator.appVersion)>3) {
document.onmousedown = mouseDown;
if (document.layers && navigator.appName=="Netscape")
  document.captureEvents(Event.MOUSEDOWN);
}
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

//document.oncontextmenu=new Function("alert(message);return false")
document.oncontextmenu=new Function("return false")

// --&gt;
&lt;/script>
</head>
<body>
right click somewhere...
</body>
</html&gt;





Attached File(s)
.html  test.html (Size: 1.43 KB / Downloads: 12)

[Image: 2604595733.png]
Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  Disable copy paste right click using javascript in asp.net textbox rajesh9147 0 3,613 11-23-2011 12:09 PM
Last Post: rajesh9147
  Capture mouse click event in javascript nisar87 3 7,753 10-10-2010 05:31 AM
Last Post: arti.porwal20@gmail.com



User(s) browsing this thread: 1 Guest(s)