Search code examples
javascriptflashzeroclipboard

ZeroClipboard: Hiding element when there is no Flash in browser


Using ZeroClipboard, as the page loads, I want to hide the "copy to clipboard" button if there is no Adobe Flash present.

I understand that there are noflash and wrongflash events, but I wonder if these can be used to effect the rendering of the page so that the button can't even be seen.


Solution

  • If you create a button with something like:

    var $button = $('.btn'),
        client = new ZeroClipboard($button);
    

    you could do something like

    client.on("error", function(e) {
         client.destroy();
         $button.hide();
    }