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 —

Do a search here for ‘document.execCommand’:
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)