Cấp bậc tác giả:

HTML

Vô hiệu hóa Kéo, chuột phải trên trang Web

Được viết bởi QuangIT ngày 24/03/2013 lúc 02:37 PM
Vô hiệu hóa Kéo, chuột phải trên trang Web
  • 0
  • 6694

Vô hiệu hóa Kéo, chuột phải trên trang Web

Vô hiệu hóa Kéo, chuột phải trên trang Web
// header javascript code

<script language="javascript" type="text/javascript">
       function killcopy(e) {
           return false
       }
       function reEnable() {
           return true
       }
       document.onselectstart = new Function("return false")
       if (window.sidebar) {
           document.onmousedown = killcopy
           document.onclick = reEnable
       }
       function disableCtrlKeyCombination(e) {
           //list all CTRL + key combinations you want to disable
           var forbiddenKeys = new Array('a', 'n', 'c', 's', 'x', 'v', 'j', 'w');
           var key
           var isCtrl;

           if (window.event) {
               key = window.event.keyCode;     //IE
               if (window.event.ctrlKey)
                   isCtrl = true;
               else
                   isCtrl = false;
           }
           else {

               key = e.which;     //firefox
               if (e.ctrlKey)
                   isCtrl = true;
               else
                   isCtrl = false;
           }

           //if ctrl is pressed check if other key is in forbidenKeys array
           if (isCtrl) {
               for (i = 0; i < forbiddenKeys.length; i++) {
                   //case-insensitive comparation
                   if (forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()) {
                       //alert("Key combination CTRL + "+String.fromCharCode(key) +" has been disabled.");
                       return false;
                   }
               }
           }
           return true;
       }
    </script>

// body tag code

<body oncontextmenu="return false;" ondragstart="return false;" onkeypress="return disableCtrlKeyCombination(event);">

YOUR SECURE CONTENT AND IMAGES HERE

</body>

Nguồn bài viết: Dngaz.com

BÌNH LUẬN BÀI VIẾT

Bài viết mới nhất

LIKE BOX

Bài viết được xem nhiều nhất

HỌC HTML