屏蔽網頁上的滑鼠和快速鍵

來源:互聯網
上載者:User

// 屏蔽滑鼠右鍵菜單
document.oncontextmenu  = function () {event.returnValue=false;}

// 屏蔽掉其他與程式無關的鍵
document.onkeydown = function () {
                                            //8 退格鍵
                                            //78 Ctrl+N
                                            //37 Alt+ 方向鍵 ←
                                            //39 Alt+ 方向鍵 →
                                            //116 F5 重新整理鍵
                                            //82 Ctrl + R
                                            //121 shift+F10
                                            //115 屏蔽Alt+F4
                                            //屏蔽 shift 加滑鼠左鍵新開一網頁
                                            if (window.event.keyCode==8
                                                || event.keyCode==78
                                                || event.keyCode==37
                                                || event.keyCode==39
                                                || event.keyCode==82
//                                                || event.keyCode==112     // F1
                                                || event.keyCode==113     // F2
                                                || event.keyCode==114     // F3
                                                || event.keyCode==115     // F4
                                                || event.keyCode==116     // F5
                                                || event.keyCode==117     // F6
                                                || event.keyCode==118     // F7
                                                || event.keyCode==119     // F8
                                                || event.keyCode==120     // F9
                                                || event.keyCode==121     // F10
                                                || event.keyCode==122     // F11
                                                || event.keyCode==123     // F12
                                                || (window.event.srcElement.tagName == "A" && window.event.shiftKey))
                                            {
                                                event.keyCode     = 0;
                                                event.returnValue = false;
                                            }
                                      }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.