Welcome to InfoPlant 4U

How To Disable Right Click on Website?

Are you a blogger or website owner looking to protect your valuable content? If so, you've come to the right place. In this article, I will show you how to disable the right-click functionality on any website, regardless of whether it's built using WordPress, PHP, HTML, or similar technologies. Blogs and websites have become popular avenues for making money online. However, many newcomers in the field, such as bloggers, developers, and website owners, often resort to copying content from well-known websites that aren't indexed on Google.



These individuals then publish the copied content on their own platforms without giving proper credit to the original creators. This practice not only denies recognition to the rightful owners but also diminishes their potential earnings. If you're concerned about safeguarding your website and its content, and would like to learn more about disabling the right-click functionality, let's dive in.


How To Disable Right Click on Website?

If you want to protect your website from content theft and unauthorized modifications, I've got you covered. In this post, I'll share some JavaScript code that will help safeguard your website from bloggers and others who duplicate content.

Some new bloggers resort to modifying copied content from other blogs and websites in hopes of generating more revenue. They believe that by doing so, their site will attract more visitors and result in higher earnings from Google AdSense. However, this approach often backfires as it lacks authenticity and fails to resonate with most readers.

To overcome this, it's essential to create your own unique content and establish a distinct pattern. By doing so, you'll enable your customers and users to recognize your content and style as truly original.

Now, let's address the issue at hand. If you're ready to disable the right-click functionality on your blog and website, follow these steps. You can choose any of the provided codes.


1. How To Disable Right Click on Website With Alert?

When the user right-clicks on the webpage, the plugin can display a pop-up box with a custom alert message.

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 disable the right click event without utilizing a JavaScript library, simply copy and paste the following JS snippets into your webpage.

document.addEventListener("contextmenu", function (e) {
  e.preventDefault();
});

2. How to Disable Right Click on a Web Page Written in HTML

If your website was built using HTML, CSS, Javascript, etc., you can use this code in the body> tag.

How to use it:

<body oncontextmenu="return false">

3. How To Disable Right Click on Website In PHP!

Additionally, you can use this code in any part of your body if you have a PHP-based website.


<script>
	window.oncontextmenu = function () {
				return false;
			}
			$(document).keydown(function (event) {
				if (event.keyCode == 123) {
					return false;
				}
				else if ((event.ctrlKey && event.shiftKey && event.keyCode == 73) || (event.ctrlKey && event.shiftKey && event.keyCode == 74)) {
					return false;
				}
			});
</script>

4. How To Disable Right Click on Website In Blogger!

If you created your blog and website with blogspot.com, you can use this code.


<script language=javascript>
	function blockOne() { 
		if (document.all) {				
				return false;
			}
			}
	function blockTwo(e) {
		if (document.layers||(document.getElementById&&!document.all)) 
		{
		if (e.which==2||e.which==3) {			
			return false;
		}
		}
		}
	if (document.layers){
		document.captureEvents(Event.mousedown);
		document.onmousedown=blockTwo;
	}
	else {
		document.onmouseup=blockTwo;
		document.oncontextmenu=blockOne;
	}
		document.oncontextmenu=new Function("return false");
</script>

5. How To Disable Right Click on WordPress Website!

On a WordPress website, you may want to prevent users from accessing certain functionalities, such as the right-click mouse button, to protect your content. This can be achieved either by utilizing a plugin called "WP Content Copy Protection" or by implementing a code snippet directly into your website's function.php file.

Using the "WP Content Copy Protection" Plugin

  • 1. Go to your WordPress dashboard and navigate to "Plugins" > "Add New."
  • 2. Search for "WP Content Copy Protection" and click on "Install Now" next to the plugin.
  • 3. Once the installation is complete, click on "Activate" to enable the plugin.
  • 4. The right-click mouse button will now be disabled on your website, preventing users from copying or accessing content using the context menu.

6. How To Disable Right Click on WordPress Website Without Plugin!

You can use this code to disable the mouse right button on your WordPress website without installing a plugin. Add this code to the function.php file on your website to use it.


function your_function() {
   ?>
<script>
jQuery(document).ready(function(){
    jQuery(document).bind("contextmenu",function(e){
        return false;
    });
});
</script>
<?php
}
add_action('wp_footer', 'your_function

By utilizing the "WP Content Copy Protection" plugin or implementing a code snippet in your website's function.php file, you can effectively disable the right-click mouse button on your WordPress website. This helps protect your content and prevents users from copying or accessing it through the context menu. Choose the method that suits your preferences and ensure that your valuable content remains secure.

Previous Post Next Post

نموذج الاتصال

CLOSE ADS