js 屏蔽浏览器事件汇总

//js 屏蔽
window.document.oncontextmenu = function () { event.returnValue = false; }//屏蔽鼠标右键 
window.document.onselectstart = function () { event.returnValue = false; }//屏蔽鼠标选择
window.window.onhelp = function (){return false } //屏蔽F1帮助 
window.document.onmousewheel = function ()//屏蔽Shift+滚轮,Ctrl+滚轮
{
    if (event.shiftKey || event.ctrlKey) {
        event.keyCode = 0;
        event.returnValue = false;
    }
}
window.document.onkeydown = function()
{
    if ((window.event.altKey) &&
        ((window.event.keyCode == 37) ||   //屏蔽 Alt+ 方向键 ← 
            (window.event.keyCode == 39)))   //屏蔽 Alt+ 方向键 → 
    {
        event.returnValue = false;
    }
    if ((event.keyCode == 116) ||                 //屏蔽 F5 刷新键 
        (event.ctrlKey && event.keyCode == 82)) { //Ctrl + R 
        event.keyCode = 0;
        event.returnValue = false;
    }
    if (event.keyCode == 32 || event.keyCode == 8)    //屏弊空格键,后退键
    {
        if (!(event.srcElement.tagName == "INPUT" && event.srcElement.type == "text") && event.srcElement.tagName != "TEXTAREA") {
            event.keyCode = 0;
            event.returnValue = false;
        }
    }
    //屏蔽F12
    if (window.event && window.event.keyCode == 123) {
        event.keyCode = 0;
        event.returnValue = false;
        return false;
    }


    if (event.keyCode == 27) { event.keyCode = 0; event.returnValue = false; }  //屏蔽ESC

    if (event.keyCode == 114) { event.keyCode = 0; event.returnValue = false; }  //屏蔽F3
    if (event.keyCode == 122) { event.keyCode = 0; event.returnValue = false; }  //屏蔽F11
    if (event.ctrlKey && event.keyCode == 67) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+c
    if (event.ctrlKey && event.keyCode == 86) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+v
    if (event.ctrlKey && event.keyCode == 70) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+f
    if (event.ctrlKey && event.keyCode == 87) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+w
    if (event.ctrlKey && event.keyCode == 69) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+e
    if (event.ctrlKey && event.keyCode == 72) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+h
    if (event.ctrlKey && event.keyCode == 73) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+i
    if (event.ctrlKey && event.keyCode == 79) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+o
    if (event.ctrlKey && event.keyCode == 76) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+l
    if (event.ctrlKey && event.keyCode == 80) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+p
    if (event.ctrlKey && event.keyCode == 66) { event.keyCode = 0; event.returnValue = false; }    //屏蔽 Ctrl+b
    if (event.ctrlKey && event.keyCode == 78) { event.keyCode = 0; event.returnValue = false; }  //屏蔽 Ctrl+n
}

 

转载于:https://www.cnblogs.com/happygx/p/7483562.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值