---
title: "js在html禁止右键的方法"
author: "maria3905"
date: "2015-06-01T11:00:32Z"
tags: []
categories: ["Web前端"]
slug: "js-html"
draft: false
lastmod: "2015-06-01T11:00:32Z"
id: 2215835
url: "https://maria3905.iteye.com/blog/2215835"
---

在html页面引入js

&lt;script type="text/javascript" src="${contextPath}js/common/preventCopy.js"&gt;&lt;/script&gt;

```
document.oncontextmenu = function(){
return false;
}
document.onkeydown = function(){
if (event.ctrlKey && window.event.keyCode==67){
return false;
}
}
document.body.oncopy = function (){
return false;
}
document.onselectstart = function(){
//return false;
}
```