How do I disable right click on my web page

0 votes
Can I disable right click on my web page without using JavaScript? I ask this because most browsers allow user to disable JavaScript.

If not, how do I use JavaScript to disable right click?
Sep 23, 2020 in Java-Script by kartik
• 37,510 points
75 views

1 answer to this question.

0 votes

Hello @kartik,

You can do that with JavaScript by adding an event listener for the "contextmenu" event and calling the preventDefault() method:

document.addEventListener('contextmenu', event => event.preventDefault());

Hope it works!!
Thank You!!

answered Sep 23, 2020 by Niroj
• 82,720 points

Related Questions In Java-Script

0 votes
1 answer

How do I modify the URL without reloading the page?

Hii @kartik, HTML5 introduced the history.pushState() and history.replaceState() methods, which allow you ...READ MORE

answered Jun 19, 2020 in Java-Script by Niroj
• 82,720 points
2,713 views
0 votes
1 answer

How do I run PHP code when a user clicks on a link?

Hello @kartik, You'd need to have a javascript ...READ MORE

answered Jul 6, 2020 in Java-Script by Niroj
• 82,720 points
1,605 views
0 votes
1 answer

How do I parse JSON with Ruby on Rails?

Hello @kartik, Use  hash = JSON.parse string Rails should automagically ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,720 points
1,583 views
0 votes
1 answer

How do I add arbitrary html attributes to input fields on a form?

Hello @kartik, If you are using ModelForm, apart from ...READ MORE

answered Jul 27, 2020 in Java-Script by Niroj
• 82,720 points
104 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5, 2020 in Java-Script by Niroj
• 82,720 points
1,339 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,720 points
169 views
+2 votes
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,720 points
172 views
0 votes
1 answer

How do I get the path to the current script with Node.js?

Hello @kartik, you can do this: fs.readFile(path.resolve(__dirname, 'settings.json'), 'UTF-8', ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,720 points
1,217 views
0 votes
1 answer

How do I call a JavaScript function on page load?

Hello @kartik, If you want the onload method ...READ MORE

answered Sep 4, 2020 in Java-Script by Niroj
• 82,720 points
4,074 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,720 points
894 views