?
Solved

Disabling right clicking image save

Posted on 2006-06-19
10
Medium Priority
?
307 Views
Last Modified: 2010-04-06
hi,

  Can you give me the code to disable the right-click image saving on web pages?

thanks
0
Comment
Question by:gstalin
[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 43

Accepted Solution

by:
TimCottee earned 2000 total points
ID: 16932685
Hi gstalin,

<script language="JavaScript1.1">
// distributed by http://www,hypergurl.com <!-- var debug = true; function
right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which
== 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer'
&& (event.button == 2 || event.button == 3)) { alert('This Page is fully
protected!'); return false; } return true; } document.onmousedown=right; if (document.layers)
window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right; //--></script>

Is one example, there are many variants of this of course.

Tim Cottee
0
 

Author Comment

by:gstalin
ID: 16932724
How to call this function and make it work?

thanks
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 16932749
gstalin,

You don't need to call it, simply place the script in the <head></head> section of your page. The script automatically assigns itself to run on the OnMouseDown event.

Tim
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:John-Bayles
ID: 16932978
<head>
<script language="JavaScript">
// distributed by http://hypergurl.com <!-- var popup="Sorry, right-click
is disabled.\n\nThis Site Copyright ©2000"; function noway(go) { if
(document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers)
{ if (go.which == 3) { alert(popup); return false; } } } if (document.layers)
{ document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; // -->
</script>
</head>

Allthough this option is very easy to get around using by:
Going File -> Save as ....Saves the page and images!
so this method is not secure at all

I would  suggest using a more full proof piece of software here are a few i found but have not tested:

http://www.programurl.com/secure-image-free.htm
http://www.programurl.com/htmlblock-html-encryption.htm
0
 
LVL 15

Expert Comment

by:Daydreams
ID: 16939794
Hi  gstalin,

There are many ways to defeat the "no-right click" script. If one can view your images, they are already downloaded to the viewer's computer). One can defeat such scripts easily:

http://javascript.about.com/library/blright.htm

A better method of protecting your images is to watermark them, which effectively embeds an image on them making them unusable:

Pictureshark is an excellent freeware, easy to use, to create watermarks:

http://pictureshark.com/

Instructions: http://pictureshark.com/step.htm
0
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 16939857
Go thru following script
www.dynamicdrive.com/dynamicindex9/noright2.htm.

and as DayDreams has said
if a user can view an image in his/her browser ,that means he has already downloaded it too the temp folder
he not needs to save it again!!

i also prefer pictureshark to create watermarks
0
 
LVL 3

Expert Comment

by:gugfuz
ID: 16942298
Even better is to put them into a Flash file.
Then they are visible, but not accesible to the user as an immage file.

Of course, he can always make a printscreen...
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 16952381
>>Of course, he can always make a printscreen...

or decompile the flash file.....



and the user needs to have a flash player installed to view your pictures.


also a nice trick, to fool some users (not too many) , is to use custom extensions, and define them in your server config as image files.
0
 

Author Comment

by:gstalin
ID: 16962055
I have used this script below,

<head>
<script language="JavaScript">
// distributed by http://hypergurl.com <!-- var popup="Sorry, right-click
is disabled.\n\nThis Site Copyright ©2000"; function noway(go) { if
(document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers)
{ if (go.which == 3) { alert(popup); return false; } } } if (document.layers)
{ document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; // -->
</script>
</head>


But the right clicking on the image is working.

How to make it work?

Thanking you


0
 
LVL 2

Expert Comment

by:murking
ID: 17011074
put shi between your <head> tags, this have been cross-browser proven...

<script language="javascript">

function clickIE4(){
if (event.button==2){
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
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("return false")
</script>

Hope this helps! Greetings,

---murki
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

770 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