js 屏蔽禁止掉浏览器自带的选中、复制、剪切、粘贴功能 1. 屏蔽选中 12345678910111213141516<script> document.onselectstart = 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; } }</script> 2. 屏蔽复制 12345678910111213141516<script> 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; } }</script> 3. 屏蔽剪切 123456789101112131415<script> document.oncut = 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. 屏蔽粘贴 12345678910111213141516<script> 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; } }</script> javascript #js #javascript js 屏蔽禁止掉浏览器自带的选中、复制、剪切、粘贴功能 https://github.com/chergn/chergn.github.io/f415136cb106/ 作者 全易 发布于 2024年3月28日 许可协议 js 将字符转为数字类型 上一篇 js 截取字符串 下一篇