aldigital Posted July 18, 2022 Share Posted July 18, 2022 Site URL: https://luciedavioud.com/ Hello everyone, I'd like to prevent visitors to copy/paste the content of the website. I found this code below but it is affecting basic functions of the site so I removed it. Any ideas how I could do that? Many thanks in advance function disableselect(e) {return false;}function reEnable() {return true;}document.onselectstart = new Function("return false");if (window.sidebar) {document.onmousedown = disableselect;document.onclick = reEnable;} function disableselect(e) {return false;}function reEnable() {return true;}document.onselectstart = new Function("return false");if (window.sidebar) {document.onmousedown = disableselect;document.onclick = reEnable;} Link to comment
derricksrandomviews Posted July 18, 2022 Share Posted July 18, 2022 (edited) I am afraid that what you want is impossible. Anyone can copy content from a site, if they know how by using screenshots, snipping software or right clicking, copy and paste or using save as function. Drag and drop is another way content is used. Disabling right click may stop some folks, but will not stop them all, and other code as you found out, when you use it, may breakl something else. Images can be watermarked using post processing software, but I don't bother because I choose to just let my work be out there. This guide will tell you more: Prevent website content downloading You can add code into your website header code injection to prevent right clicking but this will not stop screen shot grabbing or image drag and drop onto the desktop : <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> Edited July 18, 2022 by derricksrandomviews aldigital 1 Link to comment
aldigital Posted July 22, 2022 Author Share Posted July 22, 2022 Thank you @derricksrandomviews! derricksrandomviews 1 Link to comment
Samid13 Posted October 28, 2022 Share Posted October 28, 2022 Is it possible to disable on mobile device as well? I was able to disable both right click and drag drop, but I found that on iphone the images can easily be downloaded (copied). Thanks in advance. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment