From 71871616217b1cdc7ed201d6bc4738ed288ee4dd Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 14 Sep 2021 17:07:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E5=90=8E=E9=80=80=E9=94=AE?= =?UTF-8?q?=EF=BC=88Backspace=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/static/ruoyi/js/common.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js index 2c586ba5..4431bf0b 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js @@ -490,6 +490,38 @@ function loadJs(file, headElem) { else document.getElementsByTagName('head')[0].appendChild(script); } +// 禁止后退键(Backspace) +window.onload = function() { + document.getElementsByTagName("body")[0].onkeydown = function() { + // 获取事件对象 + var elem = event.relatedTarget || event.srcElement || event.target || event.currentTarget; + // 判断按键为backSpace键 + if (event.keyCode == 8) { + // 判断是否需要阻止按下键盘的事件默认传递 + var name = elem.nodeName; + if (name != 'INPUT' && name != 'TEXTAREA') { + return _stopIt(event); + } + var type_e = elem.type.toUpperCase(); + if (name == 'INPUT' && (type_e != 'TEXT' && type_e != 'TEXTAREA' && type_e != 'PASSWORD' && type_e != 'FILE')) { + return _stopIt(event); + } + if (name == 'INPUT' && (elem.readOnly == true || elem.disabled == true)) { + return _stopIt(event); + } + } + }; +}; +function _stopIt(e) { + if (e.returnValue) { + e.returnValue = false; + } + if (e.preventDefault) { + e.preventDefault(); + } + return false; +} + /** 设置全局ajax处理 */ $.ajaxSetup({ complete: function(XMLHttpRequest, textStatus) {