Disable Right Click On The Webpage With Alert

Category: Javascript | July 20, 2018
Views Total:3,781 views
Official Page:Go to website
Last Update:July 20, 2018


Disable Right Click On The Webpage With Alert


A small JavaScript plugin that disables the mouse right click on your webpage to prevent content theft.

Optionally, the plugin displays a popup box with a custom alert message when the user right clicks the webpage.

How to use it:

Just download and insert the JavaScript file ‘disableMouseRightClick.js’ into the document and done.

<script src="disableMouseRightClick.js"></script>

Customize the alert popup.

var options = {
    // Set this false to deactivate alert
    enableAlert: true, 
    // Customize this to change alert text
    alertText: "Mouse right click is disabled!" 

To simply disable the right click event on your webpage without using any JavaScript library, just copy and paste the following JS snippets to your webpage and done.

document.addEventListener("contextmenu", function (e) {

You Might Be Interested In:

Leave a Reply