Scholar

Scripts for download prevention fails when i create image URLs.

Hi everyone..

I have a bit of a problem.

I was using the scripts supplied by Robin, 05-11-2016 in my settings-SEO to prevent rightclick on my images. They worked like a charm. But when i added URL adresses to my images the codes did not work anymore and i could rightclick/save all my images. Does anyone know if there's a workaround to keep both the rightclick disabled and at the same time being able to have URL adresses available on my images?

Carlitos

7 REPLIES
Community Manager

Re: Scripts for download prevention fails when i create image URLs.

Could you paste the code you're using here, @carlitos? That code probably looks to match specific code and just needs to be updated in some way to reflect the change in image tag code.

- Adam
Community Manager
Scholar

Re: Scripts for download prevention fails when i create image URLs.

Thank you for the reply.

The codes i used in the header were:

Header kode:

<script language=JavaScript> 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>

 

<script language=JavaScript> 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>

 

The code i used in the footer was:

<body ondragstart="return false" onselectstart="return false">

 

In addition i used a ctrl+u block in the header:

<script type="text/javascript">
document.onkeydown = function (cc) {
if(cc.which == 85){
return false;
}
if(cc.which == 80){
return false;
}
}
</script>

 

Finally i added URLs to my images by left clicking my images/choosing link in the popup menu/choosing file and reuploading my images, and that's where it all went wrong. So i removed the links and went back to the codes.

 

Scholar

Re: Scripts for download prevention fails when i create image URLs.

Thank you for the reply.

The codes i used in the header were:

<script language=JavaScript> 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>

 

<script language=JavaScript> 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>

 

The code i used in the footer was:

<body ondragstart="return false" onselectstart="return false">

 

In addition i used a ctrl+u block in the header:

<script type="text/javascript">
document.onkeydown = function (cc) {
if(cc.which == 85){
return false;
}
if(cc.which == 80){
return false;
}
}
</script>

 

Finally i added URLs to my images by left clicking my images/choosing link in the popup menu/choosing file and reuploading my images, and that's where it all went wrong. So i removed the links and went back to the codes.

Community Manager

Re: Scripts for download prevention fails when i create image URLs.

Hmm.. that shouldn't have actually affected that code, since that code is basically preventing right-clicks from happening period - it doesn't care what element it is you're doing it with. What's the address of your site?

- Adam
Community Manager
Scholar

Re: Scripts for download prevention fails when i create image URLs.

Yes i agree. The site is: carlosaunmomedia.com

 

Employee Moderator

Re: Scripts for download prevention fails when i create image URLs.

I'm not familiar with the scripts you posted for this, but I have a site with disabled right click. I added the following to the Settings>SEO>Footer:

 

<body oncontextmenu="return false;">

 

I didn't need any extra codes or scripts anywhere, but maybe you are trying to accomplish something more? I tested this with the images on their own, and then also linked to a URL and a file download. Keep in mind this doesn't guarantee your photos would be protected (a screenshot can be taken, for instance) so maybe you should look into adding a watermark to your photo. There's plenty of online software you can use to do this. Smiley Happy

Scholar

Re: Scripts for download prevention fails when i create image URLs.

Thank you for the reply.

I'll check out the code u supplied. I always use watermarks, but for the webpage i wanted it to be i bit more clean so i reduced the image size and added the scripts. But when i added URLs to the images they failed and rightclick was again possible.