欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript實(shí)現(xiàn)禁止復(fù)制網(wǎng)頁內(nèi)容匯總

 更新時(shí)間:2015年12月30日 08:54:42   投稿:hebedich  
本文給大家匯總介紹了幾種使用javascript和CSS實(shí)現(xiàn)禁止復(fù)制頁面內(nèi)容的方法,非常的實(shí)用,有需要的小伙伴可以參考下。

方法一:

// 禁用右鍵菜單、復(fù)制、選擇
$(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;
  }
});

方法三:

// 設(shè)置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中(新版瀏覽器支持,并逐漸成為標(biāo)準(zhǔn)):

body {
  -moz-user-select:none; /* Firefox私有屬性 */
  -webkit-user-select:none; /* WebKit內(nèi)核私有屬性 */
  -ms-user-select:none; /* IE私有屬性(IE10及以后) */
  -khtml-user-select:none; /* KHTML內(nèi)核私有屬性 */
  -o-user-select:none; /* Opera私有屬性 */
  user-select:none; /* CSS3屬性 */
}

相關(guān)文章

最新評論