We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

NO RIGHT CLICK for Images | Forum

Kevin
Kevin Nov 30 '16
What file would the following be added too?Secure your website with JavaScript, NO RIGHT CLICK for Images

Use the script below so when someone right clicks to save an image off your page, a message will come up letting people know that your information is copyrighted.

This script may not work in all browsers, and is not foolproof. If someone really wants something from your page they can find ways around it, but at least it's a warning to people who want to take your graphics. But it certainly is a great start.

Copy and paste the following code, and make sure it comes right after your <HEAD> tag:


Found the following online: http://www.hypergurl.com/norightclick.html

<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>

Kevin
Kevin Nov 30 '16
Also found this approach. (Same question - where to implement ;)


You can stop right clicks with a script (copy and paste it from this page if you want to) in the <HEAD> section of your HTML code.<script type="text/javascript"> var msg="mouse right click disabled(or any message you want)"; function click(e) { if (document.all) { if (event.button == 2) { alert(msg); return false; } } if (document.layers) { if (e.which == 3) { alert(msg); return false; } } } if (document.layers) { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=click;


https://my.justhost.com/cgi/help/118

Tried adding  it in Index.html of the theme - no effect


==== third approach: ============ 

Suggested adding to footer code...

https://hc.weebly.com/hc/en-us/articles/201019507-Disable-Image-Downloads-


The Forum post is edited by Kevin Nov 30 '16
dave Leader
dave Nov 30 '16
I have always prefered to use these methods for such things. 


This will prevent hotlinking, only list the sites that are authorized to use images. And i usually dont allow blank referrer

# means comment and that line will not be executed



#block images by direct url all sites listed are authorized

RewriteEngine on

#RewriteCond %{HTTP_REFERER} !^http://(www.)?site1.com/      [NC]

#RewriteCond %{HTTP_REFERER} !^http://(www.)?site2.com/      [NC]

#browsers send blank referrer so block url in browser too

#you might allow here but then block in sub domain

#optional but recommended - allow blank referrer

#RewriteCond %{HTTP_REFERER} !^$

RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv|mp4)$ - [F,NC,L]

#end block


Now you can get fancy with this and if they try to hotlink you can send them to some other website  or page. I used to have a page on my website that showed a big looser logo with the text "your such a looser" when they tried to hotlink my photos. 


Now as for the right click you can wrap it in a div like this 


<div id="prevent">
whatever content here 
</div> 


then for the js part you can use the code like this 


document.getElementById('prevent').oncontextmenu = function () 

{       

  alert('We worked hard on this text - please do not copy it - that is so wrong!');


  return false;

};


or you can put that code in a file i named  jsprevent.js  and put that file in the root (make sure you add the custom file name to the htaccess) 


and then just call it like this 


<script type="text/javascript" src="jsprevent.js"></script>



if anyone right clicks in that div anywhere it will display that message and block them from the right click. 


dont forget to add the prevent.js file to your htaccess file so oxwall will accept it.

The Forum post is edited by dave Aug 13 '19
Kevin
Kevin Dec 1 '16
That sounds like a much cleaner way for the right-click. I will give it a try...

For the hot-linking, it turned out the cPanel on my hosting service already had it in place, and I only needed to add a few more file types.

Thanks.
Kevin
Kevin Dec 1 '16
I tried putting the right-click code in the Page Settings Header/Footer section (see attachment)


Didn't seem to have any effect. Did I miss something, or do I have to toggle Dev mode for these changes also?

-------- 

Alternatively, tried edit theme's html_document.html file and pasted between the <head> and before the closing </body>

The Forum post is edited by Kevin Dec 1 '16
Attachments:
  Page Settings.jpg (35Kb)
dave Leader
dave Dec 1 '16
you have to put something in the div, right now there is nothing in there to effect, its just an empty div. 


i would not put that div there,  i would put the div in the html file that you want the data effected.  I know it works because i use it all the time.  


For example find the tos html file and put the div around that, then clear your cache and you will see that it works when you try to right click on the text in the tos page. 

dave Leader
dave Dec 1 '16
the only way you are going to do this to affect everything on every page is to split up the div..


put the open div in the header section and the close div in the footer section.  But that can have bad results.

Kevin
Kevin Dec 2 '16
I ended up just using the orig code in the Page Settings header and it worked. Thanks!


Now I need to remember to remove when I want to debug with inspect element ;)

The Forum post is edited by Kevin Dec 2 '16
Gerry
Gerry Dec 2 '16
This would be a handy plugin to have.

If its possible that is.
Matthew Peter
Matthew Peter Nov 18 '21
In order to learn how to make custom code modifications, you will first need a coding or development background. You should read more reviews as This could be from a formal college degree, previous jobs in the technology field, of self-made CB1 X Code courses. In any of these cases it is recommended to take some time and focus specifically.
Nikita
Nikita Mar 15 '22
Shopian Escort ❤️ Umaria Escort ❤️ Viluppuram Escort ❤️ West Singhbhum Escort ❤️ Aizwal Escort ❤️ Amroha Escort ❤️ Anantnag Escort ❤️ Dakshin Dinajpur Escort ❤️ Jamui Escort ❤️ Kadapa Escort ❤️ Pathankot Escort ❤️ Prakasam Escort ❤️ Rajouri Escort ❤️ Surguja Escort ❤️ Valsad Escort ❤️ Bishnupur Escort ❤️ Champawat Escort ❤️ Harda Escort ❤️ Kanker Escort ❤️ Kishanganj Escort ❤️ Kurnool Escort ❤️ Ambala Escort ❤️ Barnala Escort ❤️ Lunglei Escort ❤️ Guna Escort ❤️ Mawkyrwat Escort ❤️ Perambalur Escort ❤️ Chamarajanagar Escort ❤️ Darrang Escort ❤️ Ghaziabad Escort ❤️ Rupnagar Escort ❤️ Bhandara Escort ❤️ Dhemaji Escort ❤️ Ernakulam Escort ❤️ Jalgaon Escort ❤️ Niwari Escort ❤️ Reasi Escort ❤️ Sahebganj Escort ❤️ Senapati Escort ❤️ Shravasti Escort ❤️ Upper Dibang Valley Escort ❤️ Virudhunagar Escort ❤️ William Nagar Escort ❤️ Akola Escort ❤️ Andaman And Nicobar Escort ❤️ Daman Escort ❤️ Janjgir Champa Escort ❤️ Kadmat Escort ❤️ Patiala Escort ❤️ Pratapgarh U P Escort ❤️ Rajourigarden Escort ❤️ Tamenglong Escort ❤️ Biswanath Escort ❤️ Champhai Escort ❤️ Hardoi Escort ❤️ Kannauj Escort ❤️ Kishtwar Escort ❤️ Kurukshetra Escort ❤️ Ambedkar Nagar Escort ❤️ Barpeta Escort ❤️ Madhepura Escort ❤️ Guntur Escort ❤️ Mayurbhanj Escort ❤️ Peren Escort ❤️ Daryaganj Escort ❤️ Ghazipur Escort ❤️ Sabarkantha Escort ❤️ Dhenkanal Escort ❤️ Erode Escort ❤️ Jalna Escort ❤️ Noklak Escort ❤️ Resubelpara Escort ❤️ Saiha Escort ❤️ Seoni Escort ❤️ Siang Escort ❤️ Upper Siang Escort ❤️ Visakhapatnam Escort ❤️ Wokha Escort ❤️ Alappuzha Escort ❤️ Andrott Escort ❤️ Damoh Escort ❤️ Jashpur Escort ❤️ Kagatsinghapur Escort ❤️ Preetvihar Escort ❤️ Ramanagara Escort ❤️ Tapi Escort ❤️ Bokaro Escort ❤️ Chandauli Escort ❤️ Haridwar Escort ❤️ Kanniyakumari Escort ❤️ Kodagu Escort ❤️ Kurung Kumey Escort ❤️ Amethi Escort ❤️ Barwan Escort ❤️ Madhubani Escort ❤️ Gurdaspur Escort ❤️ Meerut Escort ❤️ Phek Escort ❤️