Disable select, copy and paste of the content of H

2019-10-09 16:51发布

I want to disable select, copy and paste of the content of HTML pages in Mozilla Firefox. I have used jQuery and JavaScript to disable right-click and copy, select, paste of the contents of HTML pages and it's working fine in IE and Chrome, but not working properly in Mozilla Firefox.

Can we disable copy, paste option in Mozilla Firefox? Any suggestions?

3条回答
疯言疯语
2楼-- · 2019-10-09 17:28

Try this first work for block select and second allow to select in textarea and input field.

html,body{
        -webkit-user-select: none;
        -moz-user-select: -moz-none;
        -ms-user-select: none;
        user-select: none;
        -khtml-user-select: none;
    }
    input, textarea{
        -webkit-user-select:  text !important;
        -moz-user-select:  text !important;
        -ms-user-select: text !important;
        user-select: text !important;
        -khtml-user-select: text !important;
    }
查看更多
相关推荐>>
3楼-- · 2019-10-09 17:36

A) Apply this code in your html document inside the body tag

ondragstart=’return false’ onselectstart=’return false’ – to disable copy and paste

B) Use this script in your html document before closing the closing the head tag

<script language=JavaScript>
    var message=”Function Disabled! OR whatever text you want to show on right click”;         
    function clickIE4(){
        if (event.button==2){ alert(message); return false; }
    }
    function clickNS4(e){
        if (document.layers||document.getElementById&&!document.all){ 
            if (e.which==2||e.which==3){ 
                alert(message);
                return false; 
            } 
        }
    }
    if (document.layers){ 
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=clickNS4;
    } else if (document.all&&!document.getElementById){
        document.onmousedown=clickIE4; 
    } 
    document.oncontextmenu=new Function(“alert(message); return false”) 
</script>

C) Give security to the contents by using the css elements in body tag

EX: in css file

body {
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -o-user-select: none;
}

This is BASIC protection! Advanced users will bypass it with ease by disabling JavaScript on their browser or using firebug.

查看更多
混吃等死
4楼-- · 2019-10-09 17:50

Just copy and Paste the below javascript in your webpage:

<script language="javascript" type="text/javascript"> 
      function disableselect(e) {             
          return false 
      } 
      function reEnable() { 
          return true 
      } 

      document.onselectstart = new Function("return false") 

      if (window.sidebar) { 
          document.onmousedown = disableselect                    // for mozilla           
          document.onclick = reEnable 
      } 

      function clickIE() { 
          if (document.all) { 
              (message); 
              return false; 
          } 
      } 


      document.oncontextmenu = new Function("return false") 

      var element = document.getElementById('tbl'); 

      element.onmousedown = function () { return false; }        // For Mozilla Browser

   </script>

Note:If the above code not works for Firefox then add style="-moz-user-select:none" in the body tag which needs to be restricted alongwith the above code.

查看更多
登录 后发表回答