Andy42 Posted September 8, 2021 Share Posted September 8, 2021 Site URL: https://andyalexisbakerfineart.com Hi. Wondering what code works best for disabling right clicking on images and if there is workable code to disable dragging images to save them to downloads. I know this would not completely stop somebody, but it would help. Link to comment
Inscape Posted September 9, 2021 Share Posted September 9, 2021 I just found this guide by @tuanphan in a different post: https://beaverhero.com/squarespace-disable-right-click/. I used his header script injection to disable right clicks, but I specifically targeted images: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function () { $("img").on("contextmenu",function(e){ return false; }); }); </script> Link to comment
Inscape Posted September 9, 2021 Share Posted September 9, 2021 Actually sorry, here is a better solution I found by combining @tuanphan's solution with another post, to disable both right clicking AND drag and save: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function () { $("img").on("contextmenu",function(e){ return false; }); $("img").on("dragstart",function(e){ return false; }); }); </script> Again, this is for images ONLY. It seemed like a better option especially since I inspect elements and copy links so much using right click. If it's not clear, this should go in Settings-->Advanced-->Code Injection-->Header. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.