设置页面禁止右击 禁用f12 禁止复制粘贴 回车提交表单
1.禁用F12
document.onkeydown = function() { if (window.event && window.event.keyCode == 123) { event.keyCode = 0; event.returnValue = false; } }
2.禁用右击
document.oncontextmenu = function(event) { if (window.event) { event = window.event; } try { var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) { return false; } return true; } catch (e) { return false; } }
3.禁止复制
document.oncopy = function(event) { if (window.event) { event = window.event; } try { var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) { return false; } return true; } catch (e) { return false; } }
4.禁止粘贴
document.onpaste = function(event) { if (window.event) { event = window.event; } try { var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) { return false; } return true; } catch (e) { return false; } }
5.按回车键提交表单
$(document).keyup(function(event) { if (event.keyCode == 13) { $("提交按钮id").trigger("click"); } });