title: How to detect copy to clipboard functionality before using it
body: <p>I'm trying to create a copy function in pure JS, so no flash. The problem I've got is that I don't want to show the copy button when the browser doesn't support copying to clipboard.</p>
  
  <p>I'm using the <code>document.execCommand('copy')</code> method to do the copying to clipboard but the support for this isn't the best. For example, safari has the execCommand function but doesn't support the copy parameter. This means that I can't simply just check if the function exists.</p>
  
  <p>Because of this dodgy support I think I'm going to have to go in the way of browser detection, just like github does which I came across from looking at a <a href="https://github.com/zeroclipboard/zeroclipboard/issues/580" rel="noreferrer">zeroclipboard</a> issue. <a href="https://gist.github.com/jonrohan/81085b119d16cdd7868a" rel="noreferrer">Here</a> is the implementation I found.</p>
  
  <p>Is there a correct way to detect the user agent? I'd rather not use NavigatorID.userAgent as that is deprecated according to <a href="https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID/userAgent" rel="noreferrer">MDN</a>.</p>