Jump to content

Disabling right click on clickthrough urls

Recommended Posts

I used code injection to disable right clicks on my photos on my site.  It works on images on the pages, and even on lightboxes of images.  However, I have some gallery pages where clicking on the photo will open it in a new window for the viewer (using clickthrough URL to a jpg file).   But that new window allows the image to be right clicked and saved by viewers, which I am trying to avoid.   Does anyone know where/how to inject the code on these new windows?

Link to comment
  • Replies 5
  • Created
  • Last Reply

Hi Tuan,

I used the following as a Code Injection in Tremont, so I guess it goes to the header of each page:

<script language=JavaScript> var message="Function Disabled!"; function clickeIE4(){ 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>

It works perfectly, except for an image that is set to open in a new browser tab.

There is a workaround, where instead of opening a jpg image in a new tab on clickthrough, I could link the image to open to a new page, then create a new page myself and put the disable right click code on that page specifically.  That will be time-consuming though and I thought maybe there is a quicker mechanism.  I don't know how to code, though, these are things I've picked up from Google (or your website, which is helpful).  

 

 

Link to comment
4 minutes ago, D1whitman said:

Hi Tuan,

I used the following as a Code Injection in Tremont, so I guess it goes to the header of each page:

<script language=JavaScript> var message="Function Disabled!"; function clickeIE4(){ 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>

It works perfectly, except for an image that is set to open in a new browser tab.

There is a workaround, where instead of opening a jpg image in a new tab on clickthrough, I could link the image to open to a new page, then create a new page myself and put the disable right click code on that page specifically.  That will be time-consuming though and I thought maybe there is a quicker mechanism.  I don't know how to code, though, these are things I've picked up from Google (or your website, which is helpful).  

 

 

If you used code from this post, you can exlude some page, above code I'm not familiar

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Thanks for the post.  I still have the same issue though.  It works perfectly, but if you set an to open in a new browser window  or tab (as opposed to a lightbox, for example), then someone can one again right click on the image in that new window/tab.  They cannot do so on the original index or image page or gallery page, but they can if it opens in a new window.  I don't want to exclude it.  I want to include that new window/tab as an area where it disables right clicks.  I might just have to make the clickthrough link to a new image page instead of just to a .jpg file.  On a brand new page, I can enter CSS code injections, but I don't know how to do that when the clickthrough is set to open a .jpg file.

Link to comment
37 minutes ago, D1whitman said:

Thanks for the post.  I still have the same issue though.  It works perfectly, but if you set an to open in a new browser window  or tab (as opposed to a lightbox, for example), then someone can one again right click on the image in that new window/tab.  They cannot do so on the original index or image page or gallery page, but they can if it opens in a new window.  I don't want to exclude it.  I want to include that new window/tab as an area where it disables right clicks.  I might just have to make the clickthrough link to a new image page instead of just to a .jpg file.  On a brand new page, I can enter CSS code injections, but I don't know how to do that when the clickthrough is set to open a .jpg file.

Can you share link to your site?

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.