Skip to content

Instantly share code, notes, and snippets.

@karlazz
Last active November 20, 2016 21:05
Show Gist options
  • Select an option

  • Save karlazz/901fc11689a645dc8f45305addd6854b to your computer and use it in GitHub Desktop.

Select an option

Save karlazz/901fc11689a645dc8f45305addd6854b to your computer and use it in GitHub Desktop.
<html>
<head>
</head>
<body>
<div id="copy_initiator">Click me to Copy Text!</div>
<script src="ZeroClipboard.min.js" type="text/javascript"></script>
<script type="text/javascript">
var clip = new ZeroClipboard( document.getElementById("copy_initiator"), {
moviePath: "ZeroClipboard.swf"
} );
//this event happens upon initiating the copy
clip.on( 'dataRequested', function ( client, args ) {
clip.setText( "whatever text you want");
} );
//this event happens upon the copy finishing
clip.on( 'complete', function(client, args) {
alert("Copied text to clipboard: " + args.text );
} );
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment