Today, We want to share with you how to disable right click using jquery?.In this post we will show you disables right click in iframe using jquery, hear for write a program to disables right click menu in html page using jquery we will give you demo and example for implement.In this post, we will learn about ASP.NET Disables Right Click On Web Page And Images Using Jquery with an example.
How to disable right click on web page using jquery ?
jQuery – disables context menu right click, cut, copy and paste
index.html
<!DOCTYPE HTML> <html> <head> <title> Disable right click on my web page - www.pakainfo.com </title> </head> <body style = "text-align:center;"> <h1 style = "color:green;" > GeeksForGeeks </h1> <p id = "GFG_UP" style = "font-size: 16px; font-weight: bold;"> </p> <button onclick = "gfg_Run()"> Disable </button> <p id = "GFG_DOWN" style = "color:green; font-size: 20px; font-weight: bold;"> </p> <script> var el_up = document.getElementById("GFG_UP"); var el_down = document.getElementById("GFG_DOWN"); el_up.innerHTML = "Click on the button to disable right click"; function gfg_Run() { document.addEventListener('contextmenu', event => event.preventDefault()); el_down.innerHTML = "Right click disabled"; } </script> </body> </html>
Example: Script to Disable Mouse Right Click
<script type="text/javascript"> $(document).ready(function() { $(".disableEvent").on("contextmenu",function(){ alert('right click disabled'); return false; }); }); </script>
Script to Disable Cut Copy & Paste
<script type="text/javascript"> $(document).ready(function() { $('.disableEvent').bind('cut copy paste', function (e) { e.preventDefault(); }); }); </script>
jQuery – disable context menu for element example
<html lang="en"> <head> <title>jQuery - disable context menu for element example - www.pakainfo.com</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script> </head> <body> <div class="container"> <table border="1"> <tr> <th>Name</th> <th>Details</th> </tr> <tr class="disableEvent"> <td>Pakainfo</td> <td>Provide Online Tutorial</td> </tr> <tr class="disableEvent"> <td>Demo</td> <td>Provide Demo</td> </tr> </table> </div> </body> </html>
How to disable right click menu in html page using jquery?
$(document).contextmenu(function() { return false; });
Example 3: index.html
<!DOCTYPE html> <html lang="en"> <head> <title>How to prevent Right Click option using jquery - www.pakainfo.com</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(document).contextmenu(function() { return false; }); }); </script> </head> <body> <p>Try right-click on the page</p> <input type="text" class="myTextBox1" /> </body> </html>
I hope you get an idea about how to disable mouse click in jquery.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.