Right Click Disable Code use javascript or jquery
On my websites, I don’t want the user to see the menu that gets displayed with the mouse right-click. So I created the HTML/JavaScript code that will prevent the default right menu from popping up when the right mouse is clicked on this pop-up page. Now I use it to stop surfers from easily stealing my copyrighted images from my website.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
if (document.layers) {
//Capture the MouseDown event.
document.captureEvents(Event.MOUSEDOWN);
//Disable the OnMouseDown event handler.
$(document).mousedown(function () {
return false;
});
}
else {
//Disable the OnMouseUp event handler.
$(document).mouseup(function (e) {
if (e != null && e.type == "mouseup") {
//Check the Mouse Button which is clicked.
if (e.which == 2 || e.which == 3) {
//If the Button is middle or right then disable.
return false;
}
}
});
}
//Disable the Context Menu event.
$(document).contextmenu(function () {
return false;
});
</script>
No comments