Skip to content Skip to sidebar Skip to footer

Disable Select, Copy And Paste Of The Content Of Html Pages In Mozilla Firefox

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 co

Solution 1:

Just copy and Paste the below javascript in your webpage:

<scriptlanguage="javascript"type="text/javascript">functiondisableselect(e) {             
          returnfalse 
      } 
      functionreEnable() { 
          returntrue 
      } 

      document.onselectstart = newFunction("return false") 

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

      functionclickIE() { 
          if (document.all) { 
              (message); 
              returnfalse; 
          } 
      } 


      document.oncontextmenu = newFunction("return false") 

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

      element.onmousedown = function () { returnfalse; }        // 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.

Solution 2:

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;
    }

Solution 3:

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

<scriptlanguage=JavaScript>var message=”FunctionDisabled! OR whatever text you want to show on right click”;         
    functionclickIE4(){
        if (event.button==2){ alert(message); returnfalse; }
    }
    functionclickNS4(e){
        if (document.layers||document.getElementById&&!document.all){ 
            if (e.which==2||e.which==3){ 
                alert(message);
                returnfalse; 
            } 
        }
    }
    if (document.layers){ 
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=clickNS4;
    } elseif (document.all&&!document.getElementById){
        document.onmousedown=clickIE4; 
    } 
    document.oncontextmenu=newFunction(“alert(message); returnfalse”) 
</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.

Post a Comment for "Disable Select, Copy And Paste Of The Content Of Html Pages In Mozilla Firefox"