Try with document.execCommand('copy') which ia native in modern browsers. (don’t forget to programmatically select the text you want to be copied first — DOMElement.select())

Do a search here for ‘document.execCommand’: https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
It’s second response I think.

You’ll also find browser support there:

IE10+ Google Chrome 43+ (~April 2015) Mozilla Firefox 41+ (shipping ~September 2015) Opera 29+ (based on Chromium 42, ~April 2015)