W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2015

Re: [clipboard] Feature detect Clipboard API support?

From: Glenn Maynard <glenn@zewt.org>
Date: Wed, 11 Feb 2015 18:16:56 -0600
Message-ID: <CABirCh83q4L=KbVZm_a7naw-a53PYyq7HqHtqzh7rNam6h=o-w@mail.gmail.com>
To: Michaela Merz <michaela.merz@hermetos.com>
Cc: "James M. Greene" <james.m.greene@gmail.com>, WebApps WG <public-webapps@w3.org>
On Wed, Feb 11, 2015 at 12:34 PM, Michaela Merz <michaela.merz@hermetos.com>
wrote:

>
> AFAIK, you can't trigger a clip board request without human interaction.
>
>  $('#element).off().on('click',function(e)     {
>     var clip = new ClipboardEvent('copy');
>     clip.clipboardData.setData('text/plain','some data');
>     clip.preventDefault();
>     e.target.dispatchEvent(clip);
>     });
>
> This unfortunately won't work in my environment since my code is not
> 'trusted'.
>

Events are used to detect that something happened, not to cause the thing
to happen.  The copy event tells you that a copy happened, you don't
dispatch "copy" to cause a copy to happen.  You use regular API calls to do
that, like execCommand("copy").  You're correct that you usually can't use
that except in response to a user action, of course.

-- 
Glenn Maynard
Received on Thursday, 12 February 2015 00:17:23 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:25 UTC