Search code examples
javascriptjqueryzeroclipboard

ZeroClipboard - Check if it wasn't loaded


Really simple question here, I couldn't find it in the documentation, was hoping somebody here could point me in the right direction.

https://github.com/zeroclipboard/zeroclipboard

In ZeroClipboard there's a callback when the SWF is loaded, is there a way I can detect if it hasn't been loaded?

Here's how it currently works for when it's loaded:

client.on( "ready", function( readyEvent ) {
  // alert( "ZeroClipboard SWF is ready!" );

  client.on( "aftercopy", function( event ) {
    // `this` === `client`
    // `event.target` === the element that was clicked
    event.target.style.display = "none";
    alert("Copied text to clipboard: " + event.data["text/plain"] );
  } );
} );

Solution

  • Simply check whether ZeroClipboard object exist in window

    window.onload = function() {
        if (!('ZeroClipboard' in window)) {
            //your code
        }
    }