JS 禁止刷新和右键

时间:2014-06-24 15:18:18   收藏:0   阅读:171
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
 
<body>
 <div style="width:100px; height:100px; background:#09C;"
</body>
<script type="text/javascript">
//F5
document.documentElement.onkeydown=function(e){
    e=e||window.event;
    if(e.keyCode==116){
        if(e.returnValue){
            e.returnValue=false;
        }else{
            e.stopPropagation();
        }
        return false;
    }
}
//右键
document.documentElement.oncontextmenu=function(e){
    e=e||window.event;
    e.cancelBubble = true;
    e.returnValue=false;
    return false;
}
</script>
</html>

 没有测试

JS 禁止刷新和右键,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!