Tuesday, 21 April 2015

Enable Copy Paste On particular control using java script ( when it did on Body)




//HTML

<asp:TextBox runat="server" ID="TextBox1" onmouseover="removeAllAttrs_onmsover();" onmouseout="ADDAllAttrs_onmsout();"></asp:TextBox>


//SCRIPT

                     function removeAllAttrs_ onmsover() {
                        var element = document.body;
                         for (var i = element.attributes.length; i-- > 0; )
                             element.removeAttributeNode(element.attributes[i]);
                     }
                    
                     function ADDAllAttrs_ onmsout(element) {
                         var body = document.getElementsByTagName('body')[0];
                         body.setAttribute("oncopy", "return false;");
                         body.setAttribute("onpaste", "return false;");
                         body.setAttribute("oncut", "return false;");

                       }                  

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...