当前位置: 代码迷 >> JavaScript >> JS 障蔽刷新,屏蔽右键
  详细解决方案

JS 障蔽刷新,屏蔽右键

热度:112   发布时间:2012-10-27 10:42:26.0
JS 屏蔽刷新,屏蔽右键
// 屏蔽刷新代码
document.onkeydown=function()
{
	if ((window.event.keyCode==116) || //屏蔽 F5 
		(window.event.keyCode==122) || //屏蔽 F11 
		(window.event.shiftKey && window.event.keyCode==121) //shift+F10 
	   )
	{
		window.event.keyCode=0; 
		window.event.returnValue=false; 
	}
	if ((window.event.altKey)&&(window.event.keyCode==115)) { //屏蔽Alt+F4 
		window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px"); 
		return false; 
	}
}
// 屏蔽右键 
if (window.Event)
	document.captureEvents(Event.MOUSEUP); 
function nocontextmenu() {
	event.cancelBubble = true;
	event.returnValue = false; 
	return false; 
}
function norightclick(e) {
	if (window.Event) {
		if (e.which == 2 || e.which == 3)
			return false; 
	}
	else
		if (event.button == 2 || event.button == 3) {
			event.cancelBubble = true;
			event.returnValue = false; 
			return false;
		}
}
document.oncontextmenu = nocontextmenu; // for IE5+ 
document.onmousedown = norightclick; // for all others 

?

1 楼 daijiejun 2011-03-29  
 
  相关解决方案