1. 禁止鼠標選中文字
document.onselectstart = new Function("event.returnValue=false");
2.禁止右鍵?
document.oncontextmenu = new Function("event.returnValue=false");
3. 禁止F12鍵
document.addEventListener("keydown", function (e) {if (e.key == "F12") {e.preventDefault(); // 如果按下鍵F12,阻止事件}});
4. 使用css樣式實現禁用選中文字
user-select: none;
5. 其他樣式自己嘗試吧
-ms-user-select: none;-khtml-user-select: none;-webkit-user-select: none;-moz-user-select: none;user-select: none;