日期:2014-05-16  浏览次数:20605 次

屏蔽鼠标右键和“F5”(刷新)js代码(支持FF4.0 + IE8)

<script   language="JavaScript">  
 		 document.oncontextmenu   =   ppMousedownOfRight;     //   for   IE5+  
 		 document.onkeydown = ppPressF5;
 
if (window.addEventListener) {  
	FixPrototypeForGecko();  //是Firefox
}
/**
 * 在Firefox中获event
 */
function FixPrototypeForGecko() {
	window.constructor.prototype.__defineGetter__("event", window_prototype_get_event);
}

function window_prototype_get_event() {
	return SearchEvent();
}
function SearchEvent() {
	if (document.all)
		return window.event;

	func = SearchEvent.caller;

	while (func != null) {
		var arg0 = func.arguments[0];

		if (arg0 instanceof Event) {
			return arg0;
		}
		func = func.caller;
	}
	return null;
}

//禁止用F5键   
function ppPressF5(){   
   if(event.keyCode==116)   
    {  
	   event.keyCode=0; 
	   event.returnValue=false;  
       return   false;   
    }   
}   
    
//禁止右键弹出菜单   
function  ppMousedownOfRight(){   
	event.cancelBubble   =   true  
    event.returnValue   =   false;  
    return   false;      
}
	 </script>  
?