I'm writing a code and I display to the user a table with data from DB. The user can copy all the data manually, but I want to add a button that copy automatically the data to clipboard. How can I do this? Thanks!
            Asked
            
        
        
            Active
            
        
            Viewed 439 times
        
    0
            
            
        - 
                    Try this code `function ClipBoard() { holdtext.innerText = copytext.innerText; Copied = holdtext.createTextRange(); Copied.execCommand("Copy"); }` – shanidkv Jan 15 '15 at 07:43
- 
                    Quick internet search show some solution, this have been previously asked on SO http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript – Jaay Jan 15 '15 at 07:45
2 Answers
0
            
            
        You cannot do this with javascript. There is no browser that can allow that. It's a security issue.
- 
                    I'm not sure about that - [This website](http://flatuicolors.com/) allows you to click on HTML colors and have them pasted into your clipboard - works fine on Chrome – nicholaswmin Jan 15 '15 at 07:56
0
            
            
        If you are good with JQuery, use this Library
P.S Although it raise a security concern, most of the browsers doesn't allow it.
 
    
    
        Murtaza Khursheed Hussain
        
- 15,176
- 7
- 58
- 83
