时间: 2021-07-31 作者:daque
有的网站页面遏止运用右键和复制功效,以至连ctrl键也遏止掉了,这个功效是怎样实行的呢?本来很大略即是挪用了一段js代码罢了。底下即是实行功效所需代码:function click(e) { if (document.all) { if (event.button==1||event.button==2||event.button==3) { oncontextmenu='return false'; } } if (document.layers) { if (e.which == 3) { oncontextmenu='return false'; } }}if (document.layers) { document.captureevents(event.mousedown);}document.onmousedown=click;document.oncontextmenu = new function("return false;")
var travel=truevar hotkey=17 /* hotkey即为热键的键值,是asii码,这边99代办c键 */if (document.layers)document.captureevents(event.keydown)function gogo(e){ if (document.layers) {if (e.which==hotkey&&travel){ alert("操纵缺点.大概是您按错了按键!"); } }else if (document.all){if (event.keycode==hotkey&&travel){ alert("操纵缺点.大概是您按错了按键!"); }}}
document.onkeydown=gogo 把上头的代码另存为一个js文献,而后在想实行此功效的页面挪用即可!道高级中学一年级尺,魔高级中学一年级丈,这个本领是有相映的破译本领,只攻代码喜好者接洽用。