I want my website to not be right-clickable. I have tried finding out how and I found out. But I don't know how to disable it without an alert-box. I want nothing to happen when someone right clicks. I tried removing the alert from the code, but that didn't work.
Asked
Active
Viewed 2,004 times
-1
-
2Where's your code? – trinaldi May 21 '16 at 21:12
2 Answers
1
if (document.addEventListener) {
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
}, false);
} else {
document.attachEvent('oncontextmenu', function() {
window.event.returnValue = false;
});
}
Answer based on How to add a custom right-click menu to a webpage?
0
If you are using jQuery this would be the way to do it:
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
This should work.
-
I've submitted an edit telling the poster they need jQuery for this answer. As is, this solution would spout a bunch of errors. – s1h4d0w May 21 '16 at 21:23