Solved

Disabling right clicking image save

Posted on 2006-06-19
10
306 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 500 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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

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!

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to dynamically set the form action using jQuery.

705 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