Hiện cảnh báo khi nhấn chuột phải hay Ctrl U trên Blogspot

Chào các bạn, trong hôm nay mình sẽ hướng dẫn các bạn tạo cảnh báo khi nhấn chuột phải hay Ctrl+U trên Blogspot.

Hiện cảnh báo khi nhấn chuột phải hay Ctrl U trên Blogspot
Hình minh họa

Cách Thực Hiện

Thêm đoạn code bên dưới vào trước <body> (nếu tìm không ra có thể tìm <body)

<script id='wpcp_disable_selection' type='text/javascript'>
//<![CDATA[
var image_save_msg='Bạn không thể lưu ảnh này, nó thuộc quyền sở hữu của Star Cường IT!';
 var no_menu_msg='Menu chuột phải đã bị cấm!';
 var smessage = "Trang web này đang được bảo vệ !!";
function disableEnterKey(e)
{
 if (e.ctrlKey){
     var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox (97)
    //if (key != 17) alert(key);
     if (key == 97 || key == 65 || key == 67 || key == 99 || key == 88 || key == 120 || key == 26 || key == 85  || key == 86 || key == 83 || key == 43)
     {
          show_wpcp_message('Bạn không thể xem và lưu mã nguồn của Website.');
          return false;
     }else
      return true;
     }
}
function disable_copy(e)
{  var elemtype = e.target.nodeName;
 var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
 elemtype = elemtype.toUpperCase();
 var checker_IMG = '';
 if (elemtype == "IMG" && checker_IMG == 'checked' && e.detail >= 2) {show_wpcp_message(alertMsg_IMG);return false;}
 if (elemtype != "TEXT" && elemtype != "TEXTAREA" && elemtype != "INPUT" && elemtype != "PASSWORD" && elemtype != "SELECT" && elemtype != "OPTION" && elemtype != "EMBED")
 {
  if (smessage !== "" && e.detail == 2)
   show_wpcp_message(smessage);
    if (isSafari)
   return true;
  else
   return false;
 } }
function disable_copy_ie()
{
 var elemtype = window.event.srcElement.nodeName;
 elemtype = elemtype.toUpperCase();
 if (elemtype == "IMG") {show_wpcp_message(alertMsg_IMG);return false;}
 if (elemtype != "TEXT" && elemtype != "TEXTAREA" && elemtype != "INPUT" && elemtype != "PASSWORD" && elemtype != "SELECT" && elemtype != "OPTION" && elemtype != "EMBED")
 {
  //alert(navigator.userAgent.indexOf('MSIE'));
   //if (smessage !== "") show_wpcp_message(smessage);
  return false;
 }
} function reEnable()
{
 return true;
}
document.onkeydown = disableEnterKey;
document.onselectstart = disable_copy_ie;
if(navigator.userAgent.indexOf('MSIE')==-1)
{
 document.onmousedown = disable_copy;
 document.onclick = reEnable;
}
function disableSelection(target)
{
    //For IE This code will work
    if (typeof target.onselectstart!="undefined")
    target.onselectstart = disable_copy_ie;
 
    //For Firefox This code will work
    else if (typeof target.style.MozUserSelect!="undefined")
    {target.style.MozUserSelect="none";}
 
    //All other  (ie: Opera) This code will work
    else
    target.onmousedown=function(){return false}
    target.style.cursor = "default";
}
//Calling the JS function directly just after body load
window.onload = function(){disableSelection(document.body);};
//]]>
</script>
<script id='wpcp_disable_Right_Click' type='text/javascript'>
 //<![CDATA[
 document.ondragstart = function() { return false;}
 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 Disable context menu on images by GreenLava Version 1.0
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
     function nocontext(e) {
        return false;
     }
     document.oncontextmenu = nocontext;
 //]]>
 </script>
<div class='msgmsg-box-wpcp warning-wpcp hideme' id='wpcp-error-message'><span>error: </span>Content is protected !!</div>
<script>
 var timeout_result;
 function show_wpcp_message(smessage)
 {
  if (smessage !== &quot;&quot;)
   {
   var smessage_text = &#39;<span>Thông báo từ Star Cường IT: </span>&#39;+smessage;
   document.getElementById(&quot;wpcp-error-message&quot;).innerHTML = smessage_text;
   document.getElementById(&quot;wpcp-error-message&quot;).className = &quot;msgmsg-box-wpcp warning-wpcp showme&quot;;
   clearTimeout(timeout_result);
   timeout_result = setTimeout(hide_message, 3000);
   }
 }
 function hide_message()
 {
  document.getElementById(&quot;wpcp-error-message&quot;).className = &quot;msgmsg-box-wpcp warning-wpcp hideme&quot;;
 }
 </script>
<style type='text/css'>
 #wpcp-error-message {
     direction: ltr;
     text-align: center;
     transition: opacity 900ms ease 0s;
     z-index: 99999999;
 }
 .hideme {
     opacity:0;
     visibility: hidden;
 }
 .showme {
     opacity:1;
     visibility: visible;
 }
 .msgmsg-box-wpcp {
  border-radius: 10px;
  color: #555;
  font-family: Tahoma;
  font-size: 11px;
  margin: 10px;
  padding: 10px 36px;
  position: fixed;
  width: 255px;
  top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -130px;
    -webkit-box-shadow: 0px 0px 34px 2px rgba(242,191,191,1);
  -moz-box-shadow: 0px 0px 34px 2px rgba(242,191,191,1);
  box-shadow: 0px 0px 34px 2px rgba(242,191,191,1);
 }
 .msgmsg-box-wpcp span {
  font-weight:bold;
  text-transform:uppercase;
 }
 .error-wpcp {  background:#ffecec url(&#39;https://i.imgur.com/RLAaHMV.png&#39;) no-repeat 10px 50%;
  border:1px solid #f5aca6;
 }
 .success {
  background:#e9ffd9 url(&#39;https://i.imgur.com/lurXByx.png&#39;) no-repeat 10px 50%;
  border:1px solid #a6ca8a;
 }
 .warning-wpcp {
  background:#ffecec url(&#39;https://i.imgur.com/JeqqcuZ.png&#39;) no-repeat 10px 50%;
  border:1px solid #f5aca6;
 }
 .notice {
  background:#e3f7fc url(&#39;https://i.imgur.com/1iHVShe.png&#39;) no-repeat 10px 50%;
  border:1px solid #8ed9f6;
 }
    </style>

Chỉnh một số thông tin lại cho phù hợp cho website của bạn và lưu lại.

Lưu ý: Cảnh báo trên chỉ hiện khi bạn click quá nhiều vào nó. Chúc các bạn thành công!

Nhận xét

  1. Code dài thế! Nhìn nhức đầu @@

    Trả lờiXóa
    Trả lời
    1. Haha, vì nó không đơn giản nên phải dài thôi :v

      Xóa
    2. Dùng tool nén lại cho gọn, nhẹ nữa!

      Xóa
    3. Nhưng mà khó nhìn, cứ để thế cho dễ nhìn :v copy ra notepad dễ edit hơn.

      Xóa
  2. :3 MOD lại sao cho click một lần là hiện đê anh

    Trả lờiXóa
    Trả lời
    1. Để thé cho chất :3 Một click nó giống mấy cái kia quá.

      Xóa
    2. :v mà anh viết bài ngắn ngủn à

      Xóa
    3. Thì tập trung vào phần cách làm thôi chứ không tâm sự nhiều :3

      Xóa
  3. Share code khi ấn F12 thì hiện ra "Paused in debugger" như blog của anh đi.

    Trả lờiXóa
  4. admin Tuấn Anh ơi ra bài viết khung chưa code đi ad
    background màu trắng nha ad , bên a Phú Cường Blogger có bài nhưng background đen e k thích ạ
    [img]https://i.imgur.com/awJBB3G.png[/img]

    Trả lờiXóa
    Trả lời
    1. .post blockquote{background:#f3f3f3;margin:10px 0;text-align:left!important;padding:12px;transition:.3s;font:400 17px Monospace;letter-spacing:0;line-height:2;color:#666;max-height:400px;overflow:auto;border-left: 3px solid #dedede}
      blockquote br{display:inherit!important;padding:0!important}
      .post blockquote:hover::-webkit-scrollbar{width:5px}
      .post blockquote::-webkit-scrollbar{width:0}
      .post blockquote::-webkit-scrollbar-thumb{background:#ddd;border-radius:100px}
      .post blockquote::-webkit-scrollbar-thumb:active{background:#bbb}

      Xóa
    2. chèn ở đâu admin

      Xóa
    3. À THANKYOU ADMIN nha e làm đc r :))

      Xóa
  5. Gooddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd

    Trả lờiXóa
  6. Này hay đó em. nhưng các leecher ko thích điều này :)

    Trả lờiXóa
    Trả lời
    1. Sao lại không thích thế anh :3

      Xóa
    2. bây cảnh báo vậy sao chúng nó ctrl U để lấy code đc, ở đây là nói mấy đứa cùi bắp thôi :v

      Xóa
    3. Haha, cảnh báo tý cho chuyên nghiệp thôi chứ không có tác dụng gì nhiều vs mấy cao thủ đâu :v

      Xóa
  7. em không biết rip template nên anh em khỏi sợ mình nha haha

    Trả lờiXóa
    Trả lời
    1. Thêm cho trang nó đẹp thôi chứ biết rip thì ba cái này vượt qua dễ mà.

      Xóa
  8. bài viết rất hay, ông rảnh qua blog tôi tương tác nhé <3 www.thaiquyit.tk

    Trả lờiXóa
    Trả lời
    1. Okay, lần sau đừng trỏ link ở phần comment nữa nha :3

      Xóa
  9. Hay lắm ông ơi đã test và khá là ok

    Trả lờiXóa
  10. hay đó a. ước gì thêm nhiều thủ thuật blogger thêm nữa "3

    Trả lờiXóa
  11. Hay quá anh ơi <3! Bài viết rất chất lượng, bố cục trang trí đẹp mắt.

    Trả lờiXóa
  12. Chuyển hết mã code về dạng flash đi ��. Như kiểu webflash đấy . Đã trên nền tảng mã nguồn mở của blog vs wordpress thì những cái che giấu mã code bằng thừa . Google nó chú trọng nội dung thê thôi

    Trả lờiXóa
  13. Hay mà tiếc e ko biết ríp temp -.- nên lấy trang trí cho vui

    Trả lờiXóa

Đăng nhận xét

Bài đăng phổ biến từ blog này

Tổng hợp các công cụ hỗ trợ làm SEO

Tổng hợp tool công cụ hay cho blogger và SEO

Mẹo giảm thời gian tải trang cho web blog của bạn