Skip to main content
Email Password   helpLost your password?

Introduction

In lot of projects we want to disable right click or we want to put some message to the user on right click on form or any specified control. so to achive this i have searched lot of code on net i found lot of solutions and from that i have made my code, i hope it will help you

(Optional) Is there any background to this article that may be useful such as an introduction to the basic ideas presented?

Using the code

i have code below for displaying message on right click and also do nothing on right click. its simple.

Here is solution for displaying message on Rightclick.

         
function OnRightClick() {

if (event.button==2) {

 

alert('Hooray.... you are not view this source');

}

}

 document.onmousedown=OnRightClick

Here is solution for doing nothing on Rightclick

if you dont want any message on right click set the oncontextmenu="return false" 
<body oncontextmenu="return false">
</body>        
You must Sign In to use this message board.
 
 
Per page   
  
-- There are no messages in this forum --


Last Updated 1 Apr 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009