如何使用 jQuery 禁用右键单击?

jqueryweb developmentfront end technology

要在页面上禁用右键单击,请使用 jQuery bind() 方法。

示例

您可以尝试运行以下代码来了解如何禁用右键单击:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   $(document).bind("contextmenu",function(e){
      return false;
   });
});
</script>
</head>
<body>

<p>Right click is disabled on this page.</p>

</body>
</html>

相关文章