# JS代码简单实现禁止右键

*Published:* 2023-10-22
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2023年10月22日，已超过 180天没有更新



```
<script type="text/javascript">
document.oncontextmenu=new Function("event.returnValue=false;");
document.onselectstart=new Function("event.returnValue=false;");
</script>
```

将上面的代码加到&lt;head&gt;&lt;/head&gt;中即可禁止[右键](https://www.xarjtc.com/tag/%e5%8f%b3%e9%94%ae "查看右键此标签更多文章")。