zeroclipboard icon indicating copy to clipboard operation
zeroclipboard copied to clipboard

ZeroClipboard copy event not working in Firefox

Open GriffP opened this issue 10 years ago • 13 comments

I have the following code which works perfectly well in Chrome, but in Firefox it seems that the 'copy' event is never fired when I click the button associated with ZeroClipboard.

jQuery(document).ready(function ($)
    {
        if (document.getElementById("click-to-copy"))
    {
        // Set up data-clipboard-target for ZeroClipboard
        // by setting the id 'clipboard-source' on an element
        // ZeroClipboard will copy data from this element on load
        // but we will override this data at copy time
        var ace_content_elements = document.getElementsByClassName("ace_content");
        if (ace_content_elements.length > 0)
        {
            ace_content_elements[0].id = "clipboard-source";
        }

        var client = new ZeroClipboard(document.getElementById("click-to-copy"));

        /* On copy, replace the clipboard data with content from active instance of Ace Editor */
        /* This presumes we only have ONE Ace Editor output block on the page */

        client.on('copy', function(event)
            {
                var the_content = Drupal.settings.ace_editor.editor_instances[0].content;
               client.setData("text/plain",the_content);
           }
        );

    }

    });

The HTML button associated with the ZeroClipboard is

   <button id='click-to-copy' data-clipboard-target='clipboard-source'>Copy To Clipboard</button>

I'm using zeroclipboard-2.2.0 and Firefox 39 on Ubuntu.

I'm in despair about getting this to work! Any help much appreciated.

GriffP avatar Aug 20 '15 10:08 GriffP

I'm having the same issue. 2.X works fin on Chrome but not on Firefox 40 on OSX. I had to downgrade to 1.3.5 so that it would work on Firefox.

felipebrahm avatar Aug 20 '15 20:08 felipebrahm

GitHub's ZeroClipboard (2.1.6) appears to work fine in Firefox 42.0 (2015-08-20).

auscompgeek avatar Aug 21 '15 14:08 auscompgeek

@auscompgeek, I tried all the 2.X.X versions piblished on NPM, including 2.1.6, and all of them worked in Chrome but none on Firefox.

felipebrahm avatar Aug 21 '15 15:08 felipebrahm

@auscompgeek: GitHub has started attempting to use a native browser copy (recently implemented in Chrome and Firefox) first, then falling back to ZeroClipboard if that native API isn't available. We plan on merging that functionality into ZeroClipboard itself, though... hopefully very soon. Keep an eye on #171.

The reason this has become a problem in Firefox [only] is that Mozilla recently (in July) decided to put all versions of Flash Player on their "blocked addons" list due to a security vulnerability, so all Flash usage has become "click-to-activate" until you update to a patched version of Adobe Flash Player (which basically means the very latest version, if even). More info:

  • http://www.ghacks.net/2015/07/14/mozilla-blocks-all-versions-of-adobe-flash-in-firefox/
  • https://bugzilla.mozilla.org/show_bug.cgi?id=1182751

JamesMGreene avatar Aug 25 '15 17:08 JamesMGreene

@JamesMGreene I insist: ZeroClipboard 2.X is not working at all in Firefox. In 1.X it works though (with the click-to-activate). Do you have an example page with ZeroClipboard 2.X working on Firefox?

felipebrahm avatar Aug 25 '15 17:08 felipebrahm

Using the functionality on http://zeroclipboard.org/ worked just fine for me in:

  • Firefox 38.0.5
  • Firefox 40.0.2

System was MacOSX 10.10.4 (Yosemite). Flash Player was 18.0.0.232.

It also works it if I manually set my Firefox Flash Player addon entry to click-to-activate ("Ask to Activate") -- after activating, of course.

JamesMGreene avatar Aug 25 '15 18:08 JamesMGreene

@felipebrahm @GriffP: Please provide your Flash version info (or just a dump of running the following command in the JS console):

console.log(JSON.stringify(ZeroClipboard.state(), null, 2));

Here's my output, for example:

{
  "browser": {
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0",
    "platform": "MacIntel",
    "appName": "Netscape"
  },
  "flash": {
    "version": "18.0.0",
    "pluginType": "netscape",
    "disabled": false,
    "outdated": false,
    "sandboxed": false,
    "unavailable": false,
    "degraded": false,
    "deactivated": false,
    "overdue": false,
    "ready": true
  },
  "zeroclipboard": {
    "version": "2.2.0",
    "config": {
      "swfPath": "http://zeroclipboard.org/javascripts/zc/v2.2.0/ZeroClipboard.swf",
      "trustedDomains": [
        "zeroclipboard.org"
      ],
      "cacheBust": true,
      "forceEnhancedClipboard": false,
      "flashLoadTimeout": 30000,
      "autoActivate": true,
      "bubbleEvents": true,
      "containerId": "global-zeroclipboard-html-bridge",
      "containerClass": "global-zeroclipboard-container",
      "swfObjectId": "global-zeroclipboard-flash-bridge",
      "hoverClass": "zeroclipboard-is-hover",
      "activeClass": "zeroclipboard-is-active",
      "forceHandCursor": false,
      "title": null,
      "zIndex": 999999999
    }
  }
}

JamesMGreene avatar Aug 25 '15 18:08 JamesMGreene

copy event not working in Firefox

JSFiddle Edit: http://jsfiddle.net/JamesMGreene/k9psq1da/ View: http://fiddle.jshell.net/JamesMGreene/k9psq1da/show/ JSBin Edit: http://jsbin.com/lozuda/edit?html,js,css View: http://jsbin.com/lozuda/ CodePen Edit: http://codepen.io/JamesMGreene/pen/zxorvW View: http://s.codepen.io/JamesMGreene/full/zxorvW/

uresh avatar Sep 14 '15 09:09 uresh

my version is Firefox 40.0.3

uresh avatar Sep 14 '15 09:09 uresh

fwiw - copy event not working for my firefox 42 / Flash 19

{
  "browser": {
    "userAgent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0",
    "platform": "Win32",
    "appName": "Netscape",
    "appVersion": "5.0 (Windows)"
  },
  "flash": {
    "version": "19.0.0",
    "pluginType": "netscape",
    "disabled": false,
    "outdated": false,
    "sandboxed": false,
    "unavailable": null,
    "degraded": null,
    "deactivated": null,
    "overdue": null,
    "ready": null
  },
  "zeroclipboard": {
    "version": "2.3.0-beta.1",
    "config": {
      "swfPath": "/Scripts/zeroclipboard/ZeroClipboard.swf",
      "trustedDomains": [
    "localhost:9226"
      ],
      "cacheBust": true,
      "forceEnhancedClipboard": false,
      "flashLoadTimeout": 30000,
      "autoActivate": true,
      "bubbleEvents": true,
      "fixLineEndings": true,
      "containerId": "global-zeroclipboard-html-bridge",
      "containerClass": "global-zeroclipboard-container",
      "swfObjectId": "global-zeroclipboard-flash-bridge",
      "hoverClass": "zeroclipboard-is-hover",
      "activeClass": "zeroclipboard-is-active",
      "forceHandCursor": false,
      "title": null,
      "zIndex": 999999999
    }
  }
}

bkwdesign avatar Dec 16 '15 20:12 bkwdesign

It is OK on FF with the version v1.3.5

WangYang-Rex avatar Oct 28 '16 05:10 WangYang-Rex

@JamesMGreene Do you know when the problems with Firefox are managed? Because today I tried V2.4.0 beta.1 today, but Firefox still can't call the copy-function zeroclipboard.on( 'copy', function(event) {...}

10Bude10 avatar Dec 12 '16 10:12 10Bude10

Since each person appears to be running into a different variation of this problem but I cannot reproduce it, I would say your best bet is to watch for v2.4.0 (hoping to release it before Christmas) which will add preferred support for the native HTML Clipboard API before falling back to Flash.

JamesMGreene avatar Dec 12 '16 19:12 JamesMGreene