如何使用javascript禁用密钥组合? [英] How to disable combination of keys using javascript?

查看:109
本文介绍了如何使用javascript禁用密钥组合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

预先感谢您的回复。
我想使用javascript禁用IE的查看源快捷键。
要禁用Ctrl + C,我使用followinf函数:

Advance Thanks for the replies. I would like to disable view source shortcut key for IE using javascript. To disable "Ctrl + C", I am using the followinf function:

function disableCopy() {
     // current pressed key
     var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
     if (event.ctrlKey && (pressedKey == "c")) {
         // disable key press porcessing
         event.returnValue = false;
     }
}

任何人都可以建议如何禁用Alt + V + C组合?

Can any one suggest how to disable "Alt + V + C" combination?

推荐答案

每个浏览器都有内置功能来查看源代码或网页。我们可以做一件事。这是禁用页面中的右键单击。

Every browser has its built-in functionality to view the source code or the webpage. We can do one thing. That is disabling right click in your page.

要禁用右键单击,请使用以下代码:

For disable right click use the following code:

<SCRIPT TYPE="text/javascript">
function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</SCRIPT>

记住一件事。我们可以使用firebug或其他一些第三方工具查看此来源。所以我们不能这样做100%。

这篇关于如何使用javascript禁用密钥组合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆