Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • how to copy data to clipboard using javascript

    • 0
    • 4
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.09k
    Comment on it

    Hello all,

    Working with rich text editor a user can copy and paste the data any where in rick text editor and we wanted to remove the html format of that copied data so that only plain text can be copied.

    To do that we have to get the copied data to clipboard using javascript which can manipulate and that paste it later on.

    To do that we have following code packet :

    in HTML we have :

    <input type="text" oncopy="getData(this,event)" value="Try to copy this text">
    

    in JavaScript we have:

    function getData(x, e) {
           var copiedHtml = e.clipboardData.getData("text/html"); // This will give the copied html
           var copyText = e.clipboardData.getData("text/plain"); // This will give the copied text
           return copyText ;
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: