?
Solved

Disable right click

Posted on 2005-02-26
10
Medium Priority
?
1,764 Views
Last Modified: 2010-04-20
Hi

I have just recently opened a website at www.geocities.com for a girl friend.
I need html code or suggestions on how to disable right click. We want to protect the content on the site.

She creates decoupage paper, keyrings, etc...., and we don't want people to "steal' (download) our images.

Any suggestions welcome

Christo
0
Comment
Question by:kcarrim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 12

Accepted Solution

by:
minichicken earned 1000 total points
ID: 13410020
Hi

You can use this Javascript to disable right click. Just include it in the <head> section of your HTML

========================================================

<script language="javascript">

function disableRightClick(e)
{
  var message = "Right click disabled";
 
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers)
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      //alert(message);
      return false;
    }
  }
  else
  {
    //alert(message);
    return false;
  }
}
disableRightClick();

</script>
0
 
LVL 33

Assisted Solution

by:humeniuk
humeniuk earned 1000 total points
ID: 13410763
Different script, same idea (from www.dynamicdrive.com/dynamicindex9/noright.htm):


<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!";  // you can change this error message

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


I've used this one a few times myself - place it inside your <BODY></BODY> tags.  Keep in mind that users inherently have to download the images to view them.  This script will prevent right-click -> Save Image, but anyone other than a novice user will know that the images can be found in their temp files once they've viewed the page.
0
 
LVL 4

Expert Comment

by:HeadIdiot
ID: 13423681
Even if you disable the right-click, I can still get every picture and every line of code you have up on your server.





0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 10

Author Comment

by:kcarrim
ID: 13426893
""Even if you disable the right-click, I can still get every picture and every line of code you have up on your server.""

This i know, but this is only to keep the standard user from getting it!

I had a look at your profile. Please tell me how can you help resolve my problem.
These images were created by hand, and then scanned. We do NOT want people to steal our creations.

Please advise
0
 
LVL 33

Expert Comment

by:humeniuk
ID: 13429346
There are two answers above, kcarrim.
0
 
LVL 10

Author Comment

by:kcarrim
ID: 13429488
humeniuk , do i just copy and paste the script into my page?
0
 
LVL 10

Author Comment

by:kcarrim
ID: 13447665
Thank you Minichicken and  Humeniuk. Is there another code to disable "Save page as" ?
0
 
LVL 33

Expert Comment

by:humeniuk
ID: 13449142
Yes, you can copy and paste the script just inside the <BODY> tag of your page.

A cleaner solution is to externalize the script, ie. copy/paste the script above (without the <script language=JavaScript></script> tags) into notepad and then save as nortclick.js (or something like that).  Then insert the following line just inside the <BODY> tag of any page where you wish to disable the right-click:  <script language="JavaScript" src="nortclick.js"></script>.  Upload the nortclick.js file into any folder where there are files that call on it.

I don't believe there is a code to disable 'save page as' and I would be disappointed if there were.  You should NOT have the ability to control the user's browser or other software on their computer.  If you don't want people to have access to your work DO NOT put it on the web.

Courtesy of COBOLdinosaur, here is the definitive list of ways to protect your source code: www.vortex-webdesign.com/help/hidesource.htm.
0
 
LVL 10

Author Comment

by:kcarrim
ID: 13456885
Thanks.

I want people to see the products we have, but i want to be able to protect my content. I have visited a page recently (i can't recall the website), but anyway, when i tried to save the page, my browser returned "Error occured. The webpage could not be saved". Is this a kind of protection? If yes, how do i apply it?

If you feel that i should open a new question, i would be glad to. After all, i am not a web developer. I am just a beginner and you guys deserve the points.

Please feel free to visit the site i have created and leave your comment.

www.geocities.com/kattebazaar

Christo
0
 
LVL 33

Expert Comment

by:humeniuk
ID: 13458614
Can you provide a link to the site where you saw that message?  Sometimes the 'save as' is disabled because an image or some element of the page isn't finished loading yet.  Although in those cases, the option is generally greyed out.  This may be something different.  Again, though, even if the 'save as' is disabled the source code and page elements are completely available to the user.  If there is a way to prevent a 'save as', it would almost certainly be as a result of exploiting a vulnerability in an insecure browser (ie. Internet Explorer).  Think about it - if you could use scripting to manipulate someone's browser functions like that, wouldn't there be all sorts of malicious things you could do?

In terms of copy protection, that's what copyright law is for.  I think the music and movie industries efforts have proven conclusively that using technology to protect your assets is ultimately futile, the hackers will always be one step ahead.  The only real protection for content providers/owners is proper enforcement of the existing laws.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question