一些阻止使用者使用右鍵複製內容的方法。
1:取消右鍵事件
document.oncontextmenu = function(){
window.event.returnValue=false;
}
2:取消預設右鍵事件
window.addEventListener("contextmenu", e => e.preventDefault());
3:user-select: none 來禁止複製
body {
-webkit-user-select:none;
-webkit-touch-callout:none;
-moz-user-select: none;
}
4:複製內容會得到空白
document.body.oncopy = function(){
event.returnValue=false;
}
不過其實只要在瀏覽器按下 shift 的同時再按右鍵就可以破解就是了。