function click(e)
02 {
03 if (document.all)
04 {
05 if (event.button==1||event.button==2||event.button==3)
06 {
07 oncontextmenu='return false';
08 }
09 }
10 if (document.layers)
11 {
12 if (e.which == 3)
13 {
14 oncontextmenu='return false';
15 }
16 }
17 }
18
19 if (document.layers)
20 {
21 document.captureEvents(Event.MOUSEDOWN);
22 }
23 document.onmousedown=click;
24 document.oncontextmenu = new Function("return false;")
25
26 var trxdyel=true
27 var hotkey=17 /* hotkey即为热键的键值,是ASII码,这里99代表c键 */
28 if (document.layers)
29 document.captureEvents(Event.KEYDOWN)
30 function gogo(e)
31 {
32 if (document.layers)
33 {
34 if (e.which==hotkey && trxdyel)
35 {
36 alert('操作错误.或许是您按错键了!');
37 }
38 }
39 else if (document.all)
40 {
41 if (event.keyCode==hotkey&&trxdyel){ alert('操作错误.或许是您按错键了!'); }}
42 }
43
44 document.onkeydown=gogo
将以上JS代码写到JS文件中取名为xp.js并放入Script文件夹中,引用时需要注意设置Charset=“gb2312”,不然提示出的信息会是乱码。
页面引用:view sourceprint?1 <script src="../Script/xp.js" type="text/javascript" charset="gb2312"></script>
本文作者:网友 来源: http://www.cnblogs.com/xup_sh/archive/2010/04/14/1711626.html
CIO之家 www.ciozj.com 微信公众号:imciow