码迷,mamicode.com
首页 > 其他好文 > 详细

局域/整体禁用鼠标右键

时间:2017-04-11 13:00:42      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:str   var   onkeydown   apt   keycode   return   页面   capture   cap   

一:局域性禁用鼠标右键

onpaste="alert(‘此处可调用模特弹窗‘);return false"

二:整个页面禁用鼠标右键

 

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 trxdyel=true
var hotkey=17 /* hotkey即为热键的键值,是ASII码,这里99代表c键 */
if (document.layers)
document.captureEvents(Event.KEYDOWN)
function gogo(e)
{
if (document.layers)
{
if (e.which==hotkey && trxdyel)
{
alert(‘操作错误.或许是您按错键了!‘);
}
}
else if (document.all)
{
if (event.keyCode==hotkey&&trxdyel){ alert(‘操作错误.或许是您按错键了!‘); }}
}
document.onkeydown=gogo

 

局域/整体禁用鼠标右键

标签:str   var   onkeydown   apt   keycode   return   页面   capture   cap   

原文地址:http://www.cnblogs.com/lhl-shubiao/p/6692990.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!