// 禁用右键菜单
document.oncontextmenu = function () {
return false;
};
// 禁用键盘快捷键
document.onkeydown = function (e) {
// 阻止Ctrl + S(Windows)和Command + S(Mac)保存操作
if ((e.ctrlKey && e.key ==='s') || (e.metaKey && e.key ==='s')) {
e.preventDefault();
}
// 阻止F12打开开发者工具
if (e.keyCode === 123) {
e.preventDefault();
}
// 阻止Ctrl + U(Windows)和Command + U(Mac)查看源代码
if ((e.ctrlKey && e.key === 'u') || (e.metaKey && e.key === 'u')) {
e.preventDefault();
}
};