F12是Chrome瀏覽器的「檢查元素」介面,通過這個介面可以查看全站的源代碼,對於「部分」網站需要「防止侵權」是不利的,所以今天就來教大家如何屏蔽「F12」按鍵
教程
1、在你的源代碼中的 <head> 部分添加下列代碼(對於Wordpress來說就是添加到「頁首(header.php)」文件內)
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <script type="text/javascript"> //<!-- function no_f12(){ 	window.location="http://i-xider.com/#呵呵"; //將當前窗口跳轉置空白頁 } function ck() { 	console.profile(); 	console.profileEnd(); 	//判斷Profiles內是否存在物體,如果有的話就代表按下F12了 	if(console.clear) { 		console.clear()  	}; 	if (typeof console.profiles =="object"){ 		return console.profiles.length > 0; 	} } ck(); $("body").data("w",$(window).width()); $("body").data("h",$(window).height());//將初始窗口的高度附加到body上,作為緩存 function stop_f12(){ 	if($.browser.msie) { 		if ($("body").data("w")==$(window).width() && ($("body").data("h")-$(window).height())>50){ 		no_f12(); // IE  		} 	}else if($.browser.mozilla){ 		if( window.console && (console.firebug || console.table && /firebug/i.test(console.table())) ){ 			no_f12(); // Firefox 		} 	}else{ 		if ( $("body").data("w")==$(window).width() && ($("body").data("h")-$(window).height())>50 || (typeof console.profiles=="object" && console.profiles.length > 0)){ 			no_f12(); // Chrome and Opera 		} 	} } stop_f12(); window.onresize = function(){ 	if($("body").data("w")==$(window).width() && ($("body").data("h")-$(window).height()>50)) //判斷當前窗口內頁高度和窗口高度,如果差值大於50,那麼停止 		no_f12(); } //--> </script> | 
2、按下F12鍵,是不是沒反應啦?
預覽
參考
總結
1、關於如何屏蔽右鍵,可以查看「這篇文章」 
2、有問題可以回覆 
