<script language=Javascript>
<!--
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</script>
Disabling right click on a image
Page 1 of 15 Replies - 419 Views - Last Post: 23 August 2011 - 10:13 AM
#1
Disabling right click on a image
Posted 18 August 2011 - 05:48 PM
I know its not one of the best ideas to disable right click on image, but my friend wants to disable it so that when a user clicks on the image to see the full version of it, the user cant right click it to save. Right now, this is the code I have, but only prevents the user from right clicking the thumbnail, I would like it for when the image is in its full version, right click is disabled.
Replies To: Disabling right click on a image
#2
Re: Disabling right click on a image
Posted 18 August 2011 - 06:41 PM
Impossible and completely impractical. Anyone with any experience can download the image with no problems. Tell him to look into image obscurification instead.
#3
Re: Disabling right click on a image
Posted 18 August 2011 - 07:04 PM
Lemur, on 18 August 2011 - 07:41 PM, said:
Impossible and completely impractical. Anyone with any experience can download the image with no problems. Tell him to look into image obscurification instead.
Yeah, anyone could still do a print screen, but I was just wondering if I could take extra measures.
#4
Re: Disabling right click on a image
Posted 18 August 2011 - 07:33 PM
yes you can disable right click on image.. using jquery is the easiest way. here's the code..
and put a class on your large image.
some other code uses .bind() function to bind the contextmenu, but it's better to use .live() so that the future image will be included in the bind.
DON'T FORGET TO INCLUDE THE JQUERY LIB.
<script type="text/javascript">
$(document).ready(function(){
$("img.fullimg").live("contextmenu",function(e){
return false;
});
});
</script>
and put a class on your large image.
<img src="something.jpg" class="fullimg">
some other code uses .bind() function to bind the contextmenu, but it's better to use .live() so that the future image will be included in the bind.
DON'T FORGET TO INCLUDE THE JQUERY LIB.
This post has been edited by LiDoNg_9_0: 18 August 2011 - 07:47 PM
#5
Re: Disabling right click on a image
Posted 18 August 2011 - 09:20 PM
Not the point, any skiddie can get that by disabling js. It's impossible to have a foolproof system without some extensive obscurification.
#6
Re: Disabling right click on a image
Posted 23 August 2011 - 10:13 AM
LiDoNg_9_0, on 18 August 2011 - 08:33 PM, said:
yes you can disable right click on image.. using jquery is the easiest way. here's the code..
and put a class on your large image.
some other code uses .bind() function to bind the contextmenu, but it's better to use .live() so that the future image will be included in the bind.
DON'T FORGET TO INCLUDE THE JQUERY LIB.
<script type="text/javascript">
$(document).ready(function(){
$("img.fullimg").live("contextmenu",function(e){
return false;
});
});
</script>
and put a class on your large image.
<img src="something.jpg" class="fullimg">
some other code uses .bind() function to bind the contextmenu, but it's better to use .live() so that the future image will be included in the bind.
DON'T FORGET TO INCLUDE THE JQUERY LIB.
Will the script work even if I have another script on my page (I have a script that tells the date on my page)? Also, how do I make the JQUERY LIB, I dont know much about JQUERY, I understand the snips of code and where they go, but no the JQUERY LIB.
Thanks!
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|