標籤:http io ar java on art cti 代碼 html
做個筆記
// 禁用右鍵菜單、複製、選擇$(document).bind("contextmenu copy selectstart", function() { return false;});// 禁用Ctrl+C和Ctrl+V(所有瀏覽器均支援)$(document).keydown(function(e) { if(e.ctrlKey && (e.keyCode == 65 || e.keyCode == 67)) { return false; }});// 設定CSS禁止選擇(如果寫了下面的CSS則不需要這一段代碼,新版瀏覽器支援)$(function() { $("body").css({ "-moz-user-select":"none", "-webkit-user-select":"none", "-ms-user-select":"none", "-khtml-user-select":"none", "-o-user-select":"none", "user-select":"none" });});
防止禁用JavaScript後失效,可以寫在CSS中(新版瀏覽器支援,並逐漸成為標準):
body { -moz-user-select:none; /* Firefox私人屬性 */ -webkit-user-select:none; /* WebKit核心私人屬性 */ -ms-user-select:none; /* IE私人屬性(IE10及以後) */ -khtml-user-select:none; /* KHTML核心私人屬性 */ -o-user-select:none; /* Opera私人屬性 */ user-select:none; /* CSS3屬性 */}
摘自http://www.code-life.com/?p=440
禁止複製網頁內容