如何使用 jQuery 停用右鍵點選?


若要停用頁面的右鍵點選,請使用 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>

更新於:2019 年 12 月 11 日

3 千+ 瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.