C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Disable right click


Posted Date: 19 Jul 2008      Total Responses: 3

Posted By: suresh       Member Level: Silver     Points: 1


Hi:

I have writtern javascript code to disable Mouse right Click.it works great in all browsers except Opera.Here is my code



<html>
<head>
<body oncontextmenu="return false;">
</head>
</html>

Can any one give me a suggestion to work this code on Opera.




Responses

Author: Kumar Velu    19 Jul 2008Member Level: DiamondRating:     Points: 6
Hi,

try like this

<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
oncontextmenu='return false';

}
}

if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}

if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;

function handleKeyDown() {
if (window.event.keyCode == 116) {
event.keyCode=0;
event.returnValue=false;
}
}
document.onkeydown = handleKeyDown;
</SCRIPT>

</HEAD >

<BODY BGCOLOR="#E0E0E0" TEXT="#000080" oncontextmenu="return false"
ondragstart="return false" onselectstart="return false">
U can not right click on this page
</BODY>




Author: shanmukha kumari    21 Jul 2008Member Level: GoldRating:     Points: 6
Simply add the following code to the <BODY> section of your web page (Press Ctrl C after selecting code to copy it):


<script language=JavaScript>
<!--

//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 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")

// -->
</script>



Author: Senthil V    28 Jul 2008Member Level: GoldRating:     Points: 6
//for disabling the right click in the webpage
document.oncontextmenu=new Function("return true")

var message="Your message here";
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;")


var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")

function disableselect(e)
{
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}

function reEnable()
{
return true
}

if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else
{
document.onmousedown=disableselect
document.onmouseup=reEnable
}



Post Reply
You must Sign In to post a response.
Next : Disable Print screen,Right Click using javascript
Previous : i am using imagebutton,when I want to change the color
Return to Discussion Forum
Post New Message
Category: JavaScript

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

internet fax

Contact Us    Privacy Policy    Terms Of Use