It's not who you are underneath, it's what you do that defines you

ASP.NET[分享]屏蔽鼠标右键、Ctrl+N、Shift+F10、Alt+F4、F11、F5刷新、退格键

<html>   

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<noscript><meta http-equiv="refresh" content="0;url=about:noscript"></noscript>
<title>屏蔽鼠标右键、Ctrl+N、Shift+F10、Alt+F4、F11、F5刷新、退格键</title>
</head>
<body>
<script language="Javascript">
//屏蔽鼠标右键、Ctrl+N、Shift+F10、F11、F5刷新、退格键
function document.oncontextmenu(){event.returnValue=false;}//屏蔽鼠标右键
function window.onhelp(){return false} //屏蔽F1帮助
function document.onkeydown(){
if((window.event.altKey)&&
((window.event.keyCode==37)|| //屏蔽Alt+方向键←
(window.event.keyCode==39))){ //屏蔽Alt+方向键→
alert("不准你使用ALT+方向键前进或后退网页!");
event.returnValue=false;
}

if((event.keyCode==8)|| //屏蔽退格删除键
(event.keyCode==116)|| //屏蔽F5刷新键
(event.ctrlKey && event.keyCode==82)){ //Ctrl+R
event.keyCode=0;
event.returnValue=false;
}
if(event.keyCode==122){event.keyCode=0;event.returnValue=false;} //屏蔽F11
if(event.ctrlKey && event.keyCode==78)event.returnValue=false; //屏蔽Ctrl+n
if(event.shiftKey && event.keyCode==121)event.returnValue=false; //屏蔽shift+F10
if(window.event.srcElement.tagName=="A" && window.event.shiftKey)
window.event.returnValue=false; //屏蔽shift加鼠标左键新开一网页
if((window.event.altKey)&&(window.event.keyCode==115)){ //屏蔽Alt+F4
window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
return false;
}
}
</script>
屏蔽鼠标右键、Ctrl+N、Shift+F10、Alt+F4、F11、F5刷新、退格键

<br/>

有更好的还请分享。。
</body>
</html>

摘自:http://hi.baidu.com/liuxingwl2009/blog/item /dce7d4dfe39e6f53cdbf1a73.html




另:屏蔽页面右键及选择文本的方法

在BODY中加入以下代码
oncontextmenu="window.event.returnValue=false" ondragstart="return false" onselectstart="return false"

示例:

<HTML>
<BODY oncontextmenu="window.event.returnValue=false" ondragstart="return false" onselectstart="return false">
点击右键试试,点击左键试试能否选中我!你选不中我吧??呵~!
</BODY>
<HTML>

摘自:http://blog.csdn.net/jelink/archive/2006/08/29/1137587.aspx


以上代码只支持IE,对于火狐支持不好,现通过jquery 的方式尝试解决对火狐的支持问题,如下:
$(document)
.bind("contextmenu", function() { return false; })
.bind("selectstart", function() { return false; });
posted @ 2012-05-31 12:20  金铭杰  阅读(1294)  评论(0编辑  收藏  举报

Brick walls are there for a reason :they let us prove how badly we want things