On 2015-05-06 2:51 PM, Mike Taylor wrote:
Hey David,

On 5/6/15 13:09, dgra...@github.com wrote:
Although IE 11 supports this API as well, we have not enabled it yet.
The browser displays a popup dialog asking the user for permission to
copy to the clipboard. Hopefully this popup is removed in Edge so we
can start using JS there too. I just haven't had a chance to test with
it yet.

Thanks for mentioning this--I suspect other sites would also fall back
to Flash if our UX is similarly annoying.

Thanks David, this is really helpful. I also agree that showing UI for this feature decreases the usability to a degree that the Flash alternative may be preferred.

Right now, there isn't a reliable way to feature detect for this API
in JS. We use user agent detection instead, just for this feature. Any
suggestions here would be much appreciated.

You can use the document.queryCommandSupported()[1] or
document.queryCommandEnabled()[2] APIs to check for support.

So technically queryCommandSupported is the right way to feature detect this. Note that currently our implementation of queryCommandSupported is buggy and it returns true for all of the command names that we know of, including "cut", "copy" and "paste". Over in <https://bugzilla.mozilla.org/show_bug.cgi?id=1161721>, we'll fix our implementation so that we return true for "cut" and "copy" and false for "paste". So in Firefox, you'd be able to feature detect like this:

function isSupported() {
  return document.queryCommandSupported("copy") &&
         !document.queryCommandSupported("paste");
}

Chrome's implementation of this function is affected by <https://code.google.com/p/chromium/issues/detail?id=476508>, but it seems like it is getting fixed. I have not tested IE's implementation of queryCommandSuported yet.

Cheers,
Ehsan

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to