|
Instructions
OverviewThe Zero Clipboard JavaScript library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie. The "Zero" signifies that the library is invisible and the user interface is left entirely up to you. This library is fully compatible with Flash Player 10, which requires that the copy operation initiated by a user click event inside the Flash movie. This is achieved by automatically floating the invisible movie on top of a DOM element of your choice. Standard mouse events are even propagated out to your DOM element, so you can still have rollover and mouse down effects. Flash Player 9 is also supported. Please note that if you use the new Rich HTML feature, your users must have Flash Player 10. There is no automatic fallback to the Flash 9 movie. UsageThe following subsections describe how to use the clipboard library. SetupTo use the library, simply include the following JavaScript file in your page: <script type="text/javascript" src="ZeroClipboard.js"></script> You also need to have the "ZeroClipboard.swf" file available to the browser. If this file is located in the same directory as your web page, then it will work out of the box. However, if the SWF file is hosted elsewhere, you need to set the URL like this (place this code after the script tag): ZeroClipboard.setMoviePath( 'http://YOURSERVER/path/ZeroClipboard.swf' ); To use the new Rich HTML feature available in Zero Clipboard 1.0.7, you must set the movie path to the new "ZeroClipboard10.swf" file, which is included in the 1.0.7 archive. Example: ZeroClipboard.setMoviePath( 'ZeroClipboard10.swf' ); Or, in a custom location other than the current directory: ZeroClipboard.setMoviePath( 'http://YOURSERVER/path/ZeroClipboard10.swf' ); ClientsNow you are ready to create one or more Clients. A client is a single instance of the clipboard library on the page, linked to a particular button or other DOM element. You probably only need a single instance, but if you have multiple copy-to-clipboard buttons on your page, potentially containing different text, you can activate an instance for each. Here is how to create a client instance: var clip = new ZeroClipboard.Client(); Next, you can set some options. Setting OptionsOnce you have your client instance, you can set some options. These include setting the initial text to be copied, amongst other things. The following subsections describe all the available options you can set. Text To CopyThis function allows you to set the text to be copied to the clipboard, once the user clicks on the control. You can call this function at any time; when the page first loads, or later in an onMouseOver or onMouseDown handler. Example: clip.setText( "Copy me!" ); Hand CursorThis setting controls whether the "hand" or "arrow" cursor is shown when the mouse hovers over the Flash movie. Here is an example: clip.setHandCursor( true ); The only values accepted are true (show "hand" cursor), or false (show "arrow" cursor). The default is true. You can set this option at any time. GluingGluing refers to the process of "linking" the Flash movie to a DOM element on the page. Meaning, the library will automatically generate a movie that is the exact size of the DOM element, and float it just above the element. Since the Flash movie is completely transparent, the user sees nothing out of the ordinary. The Flash movie receives the click event and copies the current text (last set with setText()) to the clipboard (a requirement of Flash Player 10 is that a user click event inside the movie must initiate the thread that interacts with the clipboard). Also, mouse actions like hovering and mouse-down generate events that you can capture (see Event Handlers below) and set CSS classes on your DOM element too (see CSS Effects below). Here is how to glue your clip library instance to a DOM element: clip.glue( 'd_clip_button' ); You can pass in a DOM element ID (as shown above), or a reference to the actual DOM element object itself. The rest all happens automatically -- the movie is created, all your options set, and it is floated above the element, awaiting clicks from the user. The glue system is an optional implementation. If you would prefer to handle your own implementation of the Flash movie, see Custom Implementation below. Recommended ImplementationIt is highly recommended you create a "container" DIV element around your button, set its CSS "position" to "relative", and place your button just inside. Then, pass two arguments to glue(), your button DOM element or ID, and the container DOM element or ID. This way Zero Clipboard can position the floating Flash movie relative to the container DIV (not the page body), resulting in much more exact positioning. Example (HTML): <div id="d_clip_container" style="position:relative"> <div id="d_clip_button">Copy to Clipboard</div> </div> And the code: clip.glue( 'd_clip_button', 'd_clip_container' ); Note that gluing to a container element does not work with the reposition() method (see next section). Page ResizingIf the page gets resized, or something happens which moves your DOM element, you will need to reposition the movie. This can be achieved by calling the reposition() method. Example: clip.reposition(); A typical use of this is to put it inside a window.onresize handler. If for some reason your DOM element was destroyed and recreated, you can pass the new ID or DOM element reference to the reposition() method. However please note that the new element must be the same size as the previous element. The library does not (yet) support elements that change size. Note that repositioning only works if you glue using a single argument. If you glue to a parent container element, you cannot (and probably won't ever need to) call reposition(). Hiding and ShowingYou can also show and hide the Flash movie on demand, if you have an AJAX web app that dynamically changes content, potentially obscuring the clipboard button. Examples: clip.hide(); clip.show(); The show() function also calls reposition(). CSS EffectsSince the Flash movie is floating on top of your DOM element, it will receive all the mouse events before the browser has a chance to catch them. However, for convenience these events are passed through to your clipboard client which you can capture (see Event Handlers below). But in addition to this, the Flash movie can also activate CSS classes on your DOM element to simulate the ":hover" and ":active" pseudo-classes. If this feature is enabled, the CSS classes "hover" and "active" are added / removed to your DOM element as the mouse hovers over and clicks the Flash movie. This essentially allows your button to behave normally, even though the floating Flash movie is receiving all the mouse events. Please note that the actual CSS pseudo-classes ":hover" and ":active" are not used -- these cannot be programmatically activated with current browser software. Instead, sub-classes named "hover" and "active" are used. Example CSS: #d_clip_button {
width:150px;
text-align:center;
border:1px solid black;
background-color:#ccc;
margin:10px; padding:10px;
}
#d_clip_button.hover { background-color:#eee; }
#d_clip_button.active { background-color:#aaa; }These classes are for a DOM element with an ID: "d_clip_button". The "hover" and "active" sub-classes would automatically be activated as the user hovers over, and clicks down on the Flash movie, respectively. They behave exactly like CSS pseudo-classes of the same names. The CSS Effect system is enabled by default. To disable it, pass false to the setCSSEffects() method. Example: clip.setCSSEffects( false ); You can set this option at any time. Custom ImplementationIf you would prefer to instantiate the Flash movie yourself, and completely disable the entire glue and CSS systems, you can simply call the getHTML() method, which returns the actual OBJECT/EMBED tag for the Flash movie. Example: var html = clip.getHTML( 150, 20 ); The method requires that you pass in the desired pixel width and height of the movie. The returned HTML can then be inserted into a DOM element of your choice, or written to the page with document.write(). Note: Microsoft Internet Explorer seems to have a bug where the Flash External Interface (the communication layer between JavaScript and Flash) doesn't activate properly unless you insert the OBJECT tag into an element that is already appended to the DOM. So make sure you call appendChild() before you insert the HTML into the innerHTML property of your element. Event HandlersThe clipboard library allows you set a number of different event handlers. These are all set by calling the addEventListener() method, as in this example: clip.addEventListener( 'onLoad', my_load_handler ); The first argument is the name of the event, and the second is a reference to your function. The function may be passed by name (string), an actual reference to the function object, or a PHP-style object/method array: clip.addEventListener( 'onMouseDown', [myObject, 'myMethod'] ); This allows you to get back into object context by calling a specific method on a specific object, as seen in PHP. However, I suppose you could just use the JavaScript bind() function to achieve the same effect. The event names are not case sensitive, and the prefix "on" is optional. For example, the values "onLoad", "onload" and "load" all mean the same thing. Your custom function will be passed at least one argument -- a reference to the clipboard client object. However, certain events pass additional arguments, which are described in each section below. The following subsections describe all the available events you can hook. onLoadThe onLoad event is fired when the Flash movie completes loading and is ready for action. Please note that you don't need to listen for this event to set options -- those are automatically passed to the movie if you call them before it loads. Example use: clip.addEventListener( 'onLoad', my_load_handler );
function my_load_handler( client ) {
alert( "movie has loaded" );
}The handler is passed a reference to the clipboard client object. onMouseOverThe onMouseOver event is fired when the user's mouse pointer enters the Flash movie. You can use this to simulate a rollover effect on your DOM element, however see CSS Effects for an easier way to do this. Example use: clip.addEventListener( 'onMouseOver', my_mouse_over_handler );
function my_mouse_over_handler( client ) {
alert( "mouse is over movie" );
}The handler is passed a reference to the clipboard client object. onMouseOutThe onMouseOut event is fired when the user's mouse pointer leaves the Flash movie. You can use this to simulate a rollover effect on your DOM element, however see CSS Effects for an easier way to do this. Example use: clip.addEventListener( 'onMouseOut', my_mouse_out_handler );
function my_mouse_out_handler(client) {
alert( "mouse has left movie" );
}The handler is passed a reference to the clipboard client object. onMouseDownThe onMouseDown event is fired when the user clicks on the Flash movie. Please note that this does not guarantee that the user will release the mouse button while still over the movie (i.e. resulting in a click). You can use this to simulate a click effect on your DOM element, however see CSS Effects for an easier way to do this. Example use: clip.addEventListener( 'onMouseDown', my_mouse_down_handler );
function my_mouse_down_handler(client) {
alert( "mouse button is down" );
}The handler is passed a reference to the clipboard client object. onMouseUpThe onMouseUp event is fired when the user releases the mouse button (having first pressed the mouse button while hovering over the movie). Please note that this does not guarantee that the mouse cursor is still over the movie (i.e. resulting in a click). You can use this to simulate a click effect on your DOM element, however see CSS Effects for an easier way to do this. Example use: clip.addEventListener( 'onMouseUp', my_mouse_up_handler );
function my_mouse_up_handler( client ) {
alert( "mouse button is up" );
}The handler is passed a reference to the clipboard client object. onCompleteThe onComplete event is fired when the text is successfully copied to the clipboard. Example use: clip.addEventListener( 'onComplete', my_complete );
function my_complete( client, text ) {
alert("Copied text to clipboard: " + text );
}The handler is passed two arguments: a reference to the clipboard client object, and the text that was copied. DestroyingYou may want to completely destroy the clipboard client movie, for example after a successful copy-to-clipboard. This means that the user cannot click to copy additional text. To do this, simply call the destroy() method, as in this example: clip.destroy(); This will remove the Flash movie from the DOM, and completely reset the client clipboard object. If you want to reinitialize the object with another container, simply call glue() again (see Gluing above), or getHTML(). Note: For safety reasons, you may not want to call this method directly in your onComplete handler function. The reason is that the JavaScript thread originated from within the Flash movie, which you are attempting to destroy with the destroy() call. This can cause crashes in certain browsers (namely IE). Better to set a timer with setTimeout() and call destroy in its own, safe thread. ExamplesThe following are complete, working examples of using the clipboard client library in HTML pages. Minimal ExampleHere is a quick example using as few calls as possible: <html> <body> <script type="text/javascript" src="ZeroClipboard.js"></script> <div id="d_clip_button" style="border:1px solid black; padding:20px;">Copy To Clipboard</div> <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'Copy me!' ); clip.glue( 'd_clip_button' ); </script> </body> </html> When clicked, the text "Copy me!" will be copied to the clipboard. Complete ExampleHere is a complete example which exercises every option and event handler: <html>
<head>
<style type="text/css">
#d_clip_button {
text-align:center;
border:1px solid black;
background-color:#ccc;
margin:10px; padding:10px;
}
#d_clip_button.hover { background-color:#eee; }
#d_clip_button.active { background-color:#aaa; }
</style>
</head>
<body>
<script type="text/javascript" src="ZeroClipboard.js"></script>
Copy to Clipboard: <input type="text" id="clip_text" size="40" value="Copy me!"/><br/><br/>
<div id="d_clip_button">Copy To Clipboard</div>
<script language="JavaScript">
var clip = new ZeroClipboard.Client();
clip.setText( '' ); // will be set later on mouseDown
clip.setHandCursor( true );
clip.setCSSEffects( true );
clip.addEventListener( 'load', function(client) {
// alert( "movie is loaded" );
} );
clip.addEventListener( 'complete', function(client, text) {
alert("Copied text to clipboard: " + text );
} );
clip.addEventListener( 'mouseOver', function(client) {
// alert("mouse over");
} );
clip.addEventListener( 'mouseOut', function(client) {
// alert("mouse out");
} );
clip.addEventListener( 'mouseDown', function(client) {
// set text to copy here
clip.setText( document.getElementById('clip_text').value );
// alert("mouse down");
} );
clip.addEventListener( 'mouseUp', function(client) {
// alert("mouse up");
} );
clip.glue( 'd_clip_button' );
</script>
</body>
</html>Browser SupportThe Zero Clipboard Library has been tested on the following browsers / platforms:
Adobe Flash Flash Player versions 9 and 10 are supported. | ||||||||||||||||||||
There is no reason IE6 and Opera wouldn't work (in fact, I know that IE6 does work), but they're just not officially supported :-)
Is pasting supported?
Sorry andreoua, but as far as I know, Adobe doesn't allow a "paste" function.
However, if you want to simulate a paste from something previously copied using the clipboard library, you can grab the last text copied using client.clipText. So if you want to insert that into a text field, for example, you could:
document.getElementById('your_text_field_id').value = client.clipText;However, this is really just smoke & mirrors, as it doesn't really take text from your PC's clipboard. Sorry I couldn't offer anything better.
It doesn't work on IE6 or IE7, the page doesn't load and it shows a pop-up error of Operation aborted
Dear scaban,
I have tested ZeroClipboard in both IE 6 and IE 7, and it works just fine. The "Operation aborted" is a well known IE bug, and has nothing to do with ZeroClipboard. You can read more about it here:
http://support.microsoft.com/kb/927917
Good luck.
Dear jhuckaby,
I think Zero clipboard is excellent. Thank you for solving a few problems for me.
However, I don't seem to be able to manage one (simple?) thing. Taking your test page (http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/multiple.html) how can I set the background colour of an element that has been clicked on so it stands out as having been 'visited'?
RottenSod?.
Hey rottensod,
Here you go:
http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/multiple2.html
Enjoy.
- Joe
Brilliant! Thanks Joe
Hi, It's excellent.
But I found one problem. I am using this in a widget code. When I am embedding the widget on any site(like blog), copy is working, but when the file containing widget code resides on our local disk, then it does not work.
I read something here about using AIR to do paste: http://www.senocular.com/air/tutorials/clipboardtext/
I don't have any Flash dev knowledge, so it may be off the mark.
ok, it seems the code works very well. Only one request. Can you make a simple version? The code is a little BIG for such a small job.
Hi, it does work
the copy functionallity works on my page but de css i'm using on the button utilizes an image as background. Using visual studio's internal webserver the background is shown as expected but using iis the background images don't show up. Can you help me?
excellent solution. thank you for your hard work.
I'm afraid I have to agree with what "scaban" said.
I ran into TWO problems:
Please do NOTE: that I am attaching the Flash to the text boxes and not the button images so they are all indeed the same size.
All in all this is excellent work, thanks so much!!
Great job, thanks!
After HOURS of debugging I have distilled this down to it's simples possible form and it still gives an 'Operation Aborted' Error in my IE7.
Here's the simple test case HTMl file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>RoohIt: Add an Instant Highlighter Button on your Own Blog, or Web Page</title> <script type="text/javascript" src="ZeroClipboard.js"></script> </head> <body> <script language="JavaScript"> var clipArr ; </script> <input id='text0' type='text' value='abc' readonly='readonly'/> <script language="JavaScript"> clipArr = new ZeroClipboard.Client(); clipArr.setText('abc') ; clipArr.setHandCursor( true ); clipArr.glue( 'text0' ); </script> </body> </html> verbatim code blockHey roohitadmin,
Thank you for the distilled test case. However, I already know about this IE 7 bug, as does Microsoft, and they detail it here:
http://support.microsoft.com/kb/927917
And this is already written up in a ZeroClipboard? bug here:
http://code.google.com/p/zeroclipboard/issues/detail?id=4
Basically, you cannot call glue() while the page is still rendering in IE. You have to use an onLoad handler to wait for the page to complete before you can dynamically insert DOM elements (which ZeroClipboard? does).
Thanks for your response. As I process the above and try it in my code...
Q1. can I call setText() dynamically AFTER the page has loaded to alter the to-copy-to-clipboard contents? FYI: Prior to your posting, I tried the same with and without the code inside a <table> and found that the simplest case wroks while not in the table and surrounding it with <table><tr><td> and </td></tr></table> gives the "Operation Aborted:
Q2. Placement issue mentioned in previous post, are you aware of it? Text-selection possible? Single clipObject will do the trick for multiple text inputs?
Thanks!!!
cool logic! wanted to know why this is not applicable in safari
thanks
hey
I get "thingy is null" (line 14 of the javascript file) and the script is not working because of that. What am I doing wrong?
grz krike
Hello krike06,
The problem is because the parameter you entered in the clip.glue( 'd_clip_button' ) is invalid. Does a valid element with an id equals to the parameter name exists on your page ?
ex : <div id="d_clip_button"></div>
Good Luck!!
Hello,
first of all, thanks for this great script! It solved my problems. I'm pretty clueless, but even I managed to get this to work.. Yay!
I'd love to be able to achieve the following: - have the text "copy to clipboard" change to "copied to clipboard" after a user clicks on "copy to clipboard". How exactly could I achieve that?
- auto-select the entire code in advance for people who'd rather right-click and do a manual copy, rather than click on the "copy to clipboard" button
Hopefully, a charitable soul can help a clueless guy ;)
Just to echo the unanswered question of dvishwa.devanand above, why doesn't the code work on local pages too? I saved the test page to a local file, and downloaded ZeroClipboard?.swf and ZeroClipboard?.js to the same folder as the file. The page appears OK but won't copy to clipboard. Neither does the "Copy to Clipboard" box change colour on mouseover. However if I upload all the items to a website it works fine.
Other clipboard copiers like http://cfruss.blogspot.com/2009/01/copy-to-clipboard-swf-button-cross.html work both online and locally.
hey miclefebvre
thanks for that, I did have it but he couldn't find it or something like that. I know it sounds weird but it's because I'm trying to integrate this into a module for a CMS system and it turns out to be more difficult then expected.
Now I don't have an error but when I click on it nothing happens. nothing get's copied, this is the code I'm using (the link to the script is not present into that page but into another page which is included, so that's not the problem):
<div id="d_clip_button" style="border:1px solid black; padding:20px;">Copy To Clipboard</div>
Is it possible to replace existing listener? I need to replace onComplete listener every time I make reposition, not add a new one. In my case it causes multiplication of listeners.
Hi. Is there any way to use ZeroClipboard? on top of an HTML button, and make the button behave like a regular button? For example:
<button type="button" id="copyButton">Copy</button> <script type="text/javascript"> var clip = new ZeroClipboard.Client(); clip.glue('copyButton'); </script>The above code glues ZeroClipboard? to the button. I want to do something like that, and I also want the button to look like it's being pressed when the user clicks. Using just the above code, the button doesn't change in appearance at all when it's clicked. I tried using a mouseDown eventListener. But i couldn't figure out any way to make the button appear pressed by just using javascript. I realize this is a difficult thing to do, because there is a flash movie directly above the button, and the flash movie receives the click, and the button itself never actually receives the click. Also, I'd like to be able to do this in a cross-browser way (IE, Firefox, and Safari). Is anything like that possible with the current version of ZeroClipboard??
Hello Krike06, to be able to use it, I added a listener to the button :
clip.addEventListener('mouseDown', function(client) {
Hope this will help!
Hi navarun.jagatpal,
there is a page at http://nerveplexus.com/Copy_to_Clipboard.htm using ZeroClipboard?.swf that changes the button or link clicked to red on mousedown and back to blue on mouse up. You could easily change that by editing the zc_events() function. There is no ZeroClipboard?.js file. All the code is in the page and is function based rather than using the clip object which I found too involved to modify. Starting at STARTUP in the code it should be fairly easy to follow what is going on.
All you need in the ZeroClipboard? object is ZeroClipboard?.dispatch which is used by ZeroClipboard?.swf as a pointer to the event handler. In this case it is set to zc_events() which then routes the mousedown (click) event to zc_click() and this sets the text you want to copy to the clipboard.
To answer the point by dvishwa.devanand and myself about ZeroClipboard? not working for local files it will work if you make your local folder or file location trusted in your Flash security settings here http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html
Hello navarun.jagatpal,
You should try something like this : <button type="button" id="copyButton" onClick="copyFunction">Copy</button>
<script type="text/javascript">
</script>
Would it be possible to add the HTML by javascript when the document loads? I'm trying to use this in a Greasemonkey script.
plexml and miclefebvre, thanks for your responses. But neither of those solutions are working for me.
plexml, the code in the page you linked to doesn't seem to be doing anything extra that ZeroClipboard? already does. For example, it has something like this in the zc_events function:
if(eventName=='mouseDown') { // clicked down on the button document.getElementById('zc_but_'+idNum).style['color'] = 'red' }That can already be done with plain old ZeroClipboard?, if I write something like this:
clip.addEventListener( 'mouseDown', function(client) { document.getElementById('zc_but_'+idNum).style['color'] = 'red' } );Also, let me clarify with an example. If the user is using IE or Firefox under Windows XP, I want the button to look like this before they click it:
and I want the button to look like this when they click it:
I don't think that's possible to do by just changing the CSS style attributes.
miclefebvre, I tested your example and it didn't work. If you don't glue the button to anything, then there is no way for the text to actually be put on the clipboard, right? If I understand correctly, when you call clip.setText(), that doesn't put the text on the clipboard. That just sets a variable inside the flash movie. When the user actually clicks the flash movie, that's when the clipboard gets changed. Isn't that right?
Hello,
This may help some people that experience an issue with Firefox and the flash not being "clickable". Simply add the following to the glue function.
style.overflow = 'auto';
Regards,
Rob
Thank you, Jhuckaby, for a great script.
Now, if I may, a quick question.
I want to add the window.open() function as an onComplete event handler. It's quite easy:
clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { window.open('URL','windowname','width=400,height=200'); }
The problem is, I'm using ZeroClipboard? to handle multiple elements on a single page. The above code only works with one element per page. Can you or anyone else please tell me how I can get a different URL to open in a new window for each element?
Hi navarun.jagatpal,
I couldn't quite get it the same as you want but please have a look at the button now on http://nerveplexus.com/Copy_to_Clipboard.htm.
As soon as you style a standard button it loses it's rounded look. Not sure if that can be fixed. Here's the button HTML:-
and here's the javascript bit in zc_events():-
var style = document.getElementById('zc_but'+idNum).style if(eventName=='mouseDown') { // clicked down on the button zc_click(idNum) // Turn the background color darker style['backgroundColor'] = '#e1e1e1' style['borderStyle'] = 'inset' } else if(eventName=='mouseUp') { // Clicked up on the button // Turn the background back to usual style['backgroundColor'] = '#f1f1f1' style['borderStyle'] = 'outset' }Hi tehutimaat,
See if what I did at http://nerveplexus.com/Copy_to_Clipboard.htm is what you mean. There are 5 buttons each with a different ZeroClipboard? movie and each button opens a new and different window after the complete event.
It's not programmed using the clip object since I couldn't follow all that object stuff. Instead it's function based but the operation should be the same.
zc_events() receives all the events from all the 5 movies and it's easy to edit to requirements. I just added:-
else if(eventName=='complete') { my_complete(idNum, args) }and then your function modified slightly:-
function my_complete(client, text) { // Client is effectively idNum and the copied text is args. // There are 5 buttons on the page with idNum's 1 to 5. // Each button has a different flash movie. var URL = 'test' + client + '.htm' window.open(URL, 'windowname'+text, 'width=400,height=200') return}@Joseph Thanks a lot for your great library.
@navarun.jagatpal At Passpack I use ZeroClipboard? in Passpack 7 putting the flash object into a div and moving the div over the icon associated with the entry fields using a mouseover event. With this simple trick, I can instance just one object and dinamically change what it copies and the callback function. I suggest you to adopt a similar approach.
To those that run into the same problem I did:
The problem: Any time I generated a new clickable flash area, although I'd already hidden the css for the div, the old flash click location remained (albeit invisibly).
The solution: Generate the clickable area only once (on load) and when you want to hide it, move the css left -1000px, then reposition the flash, so that it's off the page, but such that you can move it back on (without creating a new flash element).
I recognize that you should be able to destroy and then regenerate a new clip, but for whatever reason I was unable to do that without bugs. Good luck out there!
(And thanks for the sweet script!)
Hi plexml,
If i have like 100 buttons on each page..will your code open new window for each click? function my_complete(client, text) {// Client is effectively idNum and the copied text is args.// There are 5 buttons on the page with idNum's 1 to 5.// Each button has a different flash movie.var URL = 'test' + client + '.htm'window.open(URL, 'windowname'+text, 'width=400,height=200')return}
like Joseph's code is not doing that i guess?
Can we have open a new window for each click on the box?
clip.addEventListener( 'onComplete', my_complete );
window.open(url,'blank')the above code is works fine for 1st time but if i click 5th box its opening all 5 windows?
is there any other way to do this?
Thanks
Hello jhuckaby,
I have this problem with Zero Clipboard - I generate output in javascript which contains multiple lines. The output can be copied to the clipboard by zeroclipboard. However there is a problem under Windows XP (and Firefox 3.0.10) - if I paste the output to notepad, new lines are displayed as strange characters. However copy/paste to word or to wordpad works so it tells me Zero Clipboard is using Unix style newlines?
I tried to use '\n\r' and '\r\n' as well as suggested in other comment but it did not work. Do you please have any hint how I can make it work with notepad?
Thank you very much!!!!
Hey jaivuk, try this:
http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/dos_line_endings.html
This is the code to convert any text to use DOS line endings (which plays nice with Windows Notepad):
clip.setText( $('fe_text').value.replace(/([^\r])\n/g, "$1\r\n") );Hi
Can you please give us a full example of using the getHTML in a page? I tried doing this:
document.write(clip.getHTML( 150, 20 ));
And that completely destroys the page: it all goes blank with just the flash object showing, and Firefox stalls with loading the page.
Cheers, Pierre
PS - We exchanged emails about ZC back in January if you want my email address.
Hi,
I tried to use this in a page that was served up as xhtml:
In firefox 3.0.11 and I got this error:
[Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://localhost/condor/javascripts/ZeroClipboard.js?1245498836 :: anonymous :: line 120" data: no]
I tried poking at the code some. For example, I tried making the if test in getHTML true so I would use an object tag and its the same result.
This may be the same as why Google ad words does not work. The solution there is to put an object in the original page that is of type html.
Any way to use this script, and then after it copys to the clipboard, to close the window it was run from?
This works ok except that from time to time in firefox, there is a problem with focus. The movie sometimes needs focus to be changed on the page to make it work properly.
I'm having problems using this offline. I downloaded the latest version and extracted the gz. I opened test.html, and clicked the copy button, but it wouldn't copy. However, when I uploaded it to my site and tested it, it worked fine - I uploaded test.html, ZeroClipboard?.js, and ZeroClipboard?.swf.
Thanks for the help, and thank you for creating this library. I've been looking for a cross-platform way to copy text to the clipboard, and this library does just that.
Hey crossthei.thet, the reason you cannot use ZeroClipboard? offline is due to a Flash permission thing. You have to edit your Flash settings and allow access for your local page. See this comment posted earlier on this page:
To answer the point by dvishwa.devanand and myself about ZeroClipboard? not working for local files, it will work if you make your local folder or file location trusted in your Flash security settings here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html
Thanks, and good luck!
- Joe
Awesome, thanks! Sorry I missed the previous response. I searched for "offline", but I guess "local" should have been the keyword I seached for.
Thanks again.
I simply wish to use the button in a flash website- no html. I am a beginner with actionscript. Can someone suggest how I would use this code with a button instance in Flash timeline? Thanx.
geigreg, I googled for "actionscript copy to clipboard". The first search result has your answer:
http://www.flashmove.com/forum/showthread.php?t=25204
ah, thanks so much. i was googling "flash" when i should have used "actionscript"...that's how i discovered this thread...i will try this one. thanks again!
I have table that lists shortened URLS. In the table is a delete button and a copy to clipboard button. I can glue a seperate instance to each copy button, which grabs the correct URL from the table. I can also delete the appropriate instance of ZeroClipboard? if the corresponding row is deleted. What I'm having trouble with is repositioning every remaining instance. I know I can reposition individual instances like so:
ZeroClipboard?.clientsinstanceNumber?.reposition();
But how could I change this command so that every remaining instance is repositioned?
Cheers, Alex
Ah, I just counted the number of elements that I had glued ZeroClipboard? to (they all had the same class, so I used jQuery's size() function) and then ran a for loop, with i=0; i<totalNumberOfElements; i++ and then var count = i + 1; ZeroClipboard?.clientscount?.reposition();
Thanks for the script! I've been struggling to get this to work with jQuery (yes, I've checked out the multiples example page). Here's what I've got:
<a href="http://www.google.com" class="copy">copy</a> <a href="http://www.bing.com" class="copy">copy</a> <script type="text/javascript"> var clip = null; $(function() { clip = new ZeroClipboard.Client(); clip.setHandCursor(true); $('.copy').mouseover(function() { var txt = $(this).attr("href"); clip.setText(txt); if (clip.div) { clip.receiveEvent('mouseout', null); clip.reposition(this); } else { clip.glue(this); } clip.receiveEvent('mouseover', null); }); }); </script>On hover the <a> gets the class name of "hover" and the clip.div positions itself appropriately. But two things don't happen:
1. on click nothing is ever copied to the clipboard 2. the mouse cursor isn't rendered as a hand despite this CSS rule:
a.copy.hover { cursor: pointer !important; }Any ideas what the problem is? Many thanks!
gmacgregor: I have never been able to glue to inline elements such as an anchor (because these don't necessarily occupy a rectangle -- they could span lines). You need to glue to a block element such as a "DIV".
Don't assign the "cusror" CSS property to a subclass like ".hover". Just assign it to "a.copy".
a.copy { cursor: pointer }Good luck.
Thanks for the reply. I should note that the anchor mentioned above is styled as an inline-block. Regardless, I tried this code in a completely different file:
$(document).ready(function() { $('#copy').mouseover(function() { var txt = $(this).attr("rel"); clip = new ZeroClipboard.Client(); clip.setHandCursor(true); clip.setText(txt); clip.glue(this); clip.addEventListener('complete', function(client, text) { $('#copied').text(text + ' copied to the clipboard!').fadeIn("slow").fadeOut(2000); }); }); }); <div id="copied" style="display: none;"></div> <div id="copy" rel="ZeroClipboard Test!">copy</div>...and everything works as expected! So I guess the issue in my other file is somehow related to a styling.
Turns out my problem was the path to ZeroClipboard?.swf was not set correctly. Let my hours of hair pulling be a lesson: make sure you set your ZeroClipboard?.moviePath correctly!
hi everyone, Is there any reason that this would work in Firefox and not Explorer (on a Windows machine)? The code I am using is as follows....I'd appreciate any help (as I'm clearly a JavaScript? amateur).
I have a JSP page that reads the URL to be copied from a Java Bean (value set by another component).
What I wish to achieve is that the JSP loads into a pop- up window, displaying the URL that is copied to the window, followed by a 'close' button. So this means the copy to clipboard has to be done on the initial load of the JSP, not by clicking a 'DIV' item or the close button on the page.
How can this be done, as I don't have a 'glue' element that has to be clicked?
Many thanks!
help!
1.not well-formed file:///D:/JavaProjects/YUI/WebRoot/examples/ZeroClipboard.js Line 1 2.syntax error file:///D:/JavaProjects/YUI/WebRoot/examples/ZeroClipboard.swf Line 1hope any guys can give some useful advice,thanks advance!
hi everyone!
i have a little problem with zeroClipboard: when i visit the sample you give everything is OK but when i copy-paste the code it does not works for me - i have the .swf and .js files in place, - they are included properly, - the flash object shows up in place, - but it does nothing on click the event handlers seems to have no effect... any suggestions?
Thanks for some wonderful work here. One really weird bug I had a tremendous amount of trouble resolving had to do with IE7 - and only IE7, 8 was fine - somehow letting the padding-top of a large div (the boundary of which was nowhere near the button div or the swf) push down the swf object below the div it was glued to. So if you moused over below the div, the hover state was activated but no dice otherwise.
I don't understand why this would be - perhaps it's just my own ignorance but it may also be a very obscure bug. (I fixed it with some conditional statements that took off the padding-top in IE7 and used margin-top for internal elements...)
Anyhow, if you'd like to see the code, shoot me an email at pselker at burnesscommunications dot com.
Thanks for your great plugin!
One question or suggestion: how to add a tooltip to the glued DOM element?
Indeed when you glue the DOM element, the "title" is no more available. Which is not really smart when the button used to copy in clipboard is an image/icon for example.
Thanks for your work
SliN
following is my code, which works fine in firefox and chrome, but giving bug in IE7.. i dont know what im doing wrong, can you please guide me
$("input[name='htmlcode'], input[name='directlink'], input[name='emaillink'], input[name='imgcode']").live('mouseover', function() { clip = new ZeroClipboard.Client(); clip.setHandCursor(true); clip.setText($(this).val()); var width = $(this).width(); var height = $(this).height()+10; var flash_movie = '<div>'+clip.getHTML(width, height)+'</div>'; flash_movie = $(flash_movie).css({ position: 'relative', marginBottom: -height, width: width, height: height, zIndex: 101 }) .click(function() { $(this).next('input').indicator({className: 'copied', wrapTag: 'div', text: 'Copied!', fadeOut: 'slow', display: 'after'}); }) .insertBefore(this); });It seems ZeroClipboard? doesn't work in ie8. I have the following error : In french : "Erreur d'exécution Microsoft JScript: Cet objet ne gère pas cette propriété ou cette méthode" I have translated the error to english : "Runtime Error Microsoft JScript: Object does not support this property or method"
this is for the following Javascript code. try { document.getElementById("ZeroClipboardMovie?_1").SetReturnValue?(flashtoXML(ZeroClipboard?.dispatch("1","load",null)) ); } catch (e) { document.getElementById("ZeroClipboardMovie?_1").SetReturnValue?("<undefined/>"); } The '}' before the catch is highlighted by the debugger.
This is very strange. I have version 10.0.22.87 of Flash player installed.
It works well in another "real" browser like FF or Chrome.
Hi thanks for the great code...i have a few issues and would be very grateful if anyone can help. Its working so far, but i have noticed that it didn't work in any IE browsers is there any reason for that? Also when i use it with a hidden div similar to what you have on your comment input, as you click a div appears. The problem is everything gets position 20px lower but the flash movie stays in the same spot? Can you help.
Here's part of the code
<div id="btn_container" style="position:relative;> <input type="submit" value="Copy" class="shorten_btn" id="copy" /></div> <script type="text/javascript" src="ZeroClipboard.js"></script> <script> var val = document.getElementById('textarea').value; var clip = new ZeroClipboard?.Client(); clip.setText( val ); clip.glue( 'copy', 'btn_container' ); </script>Hey everyone. I have been receiving multiple reports that ZC is not working in IE. I cannot reproduce, and would like to have more information (i.e. what Flash version, etc.) to help track down the issue. Here are screenshots of ZC 1.0.5 working in IE6, IE7 and IE8.
Thanks!
Hey powermikee, regarding movie position: If you are having trouble getting the movie to position itself properly, please consider not using the glue() method, but instead just grab the raw HTML for the Flash move using getHTML(), and position it yourself wherever you like. Good luck!
Hello! This is indeed nice script! I'm using it for making large form that has multiple text inputs with dynamic text inside (read only) to copy each inputs separately. Form is generated by php.
Is it possible to copy varying content that is generated by ajax ? How should i make the glue to each varying element? Or does this even support copying ajax generated multiple text element copying ?
I got this to work in Firefox but not Safari in 10.5.8 -- is there anything I can do to make it work in Safari?
Is it possible to send a click event to the flash object or does it only work when a user clicks? I would like to bind a key to copy.
Thanks, -ml
when send glue is not id,it get mistakes in ie6.7. my code
Please give me a help.
Hello and thank you for the script. It is very useful and a powerful thing to have.
I have gotten your code to work for every scenario I can think of but I what I'm doing in the end is basically copying the html content within a <div> to the clip board. Unfortunately I do not get the same affect as one would get when you just highlight and copy a html onto an email. When doing a manual copy you bring along the styles with the copy and paste but while using this script you will get the actual code rather than an html entity.
Thanks for your help and again, great script.
Does anyone have an example using ZeroClipboard? on a page with multiple instances? I'm assuming there's an implementation without re-instantiating a new ZeroClipboard? object for each item. I've noticed some browsers crash on a large number of instances.
@recaffeinated: Yes, there is a link to a demo on the main project page, which does what you want. URL:
http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/multiple.html
I can't get this to work in IE or the new Chrome beta, but the copying is working on FF3.5. I'm running WinXP 64-bit.
Hi, great work. But I don't understand the sample: The texterea has an event onchange="clip.setText(this.value)". But the text will only be set after the button click... Is there also a way to use something like onchange to set the text?
Hello,
I'm trying to implement this to my blog (I want to create a button, which gets the current page's URL text and copies it to clipboard).
I've managed to get the url text via a php code but couldn't get this flash work.
I've tried the sample codes on this page, and they work. When I put the same code to wordpress single.php file movie does not load.
I'm putting the movie to the same location with single.php but it does not work. (but test code works)
can anyone help me? I've spent hours but could not solve the problem.
It's great to be able to copy plain text, but it would be even better to copy text WITH formatting (i.e. with HTML tags, to create rich text). I would think that this would require an update of the flash file. Is this in the works ?
Hi, I want to use setText inside an element(using onClick, href="javascript: etc), but so far I can't succeed.. Below is the code I'm using right now:
<script src="ZeroClipboard.js"></script> <span onclick="clip.setText('swell');" id="clip">Copy swell to Clipboard</span> <span onclick="clip.setText('neat');" id="clip">Copy neat to Clipboard</span> <script> clip=new ZeroClipboard.Client(); clip.glue('clip'); </script>This doesn't seem to work.. Any Ideas?
@linbrek: onclick is too late, because the flash movie is "floating" above your element, intercepting all click events. you have to use "onmouseover" to set the text.
Is there any way to change the cursor? We have a custom cursor (.cur file) that we use with CSS to identify copy-able text. I've tried setting a cursor property on the embed, object, zeroclip div, and the container for the text to be copied. Nothing seems to work.
Thanks!
@linbrek: The first problem I see is that you have two elements with the same ID (clip). Thats no good.
multiple ZeroClipboard? in the same page - facebook smileys
In windows version of safari, it showing white block (not transparent), and is there is way to avoid this. And i want to style link on mouse over.
very nice script! tnx a lot!
this what is working for me, had a hard time on this..
make sure that <a> is the same size as image than copy paste to your script. otherwise the click wont work.
in this script when user presses on the <a> it copies to clipboard the content of <input>
<head> <script type="text/javascript" src="zeroclipboard/ZeroClipboard.js"></script> <script>
</script></head>
<body>
</body>Hi, It's excellent. thanks!
I'm not getting this at all. I've heavily reused examples provided to make my own, and every time I press the button, it seems to require me to click twice to actually manage to do the copying. If I add alerts, I see that the first time, only the 'oncomplete' event triggers ("copied"), and the second time, only the 'mousedown' one. This makes no sense... I'm not resizing the window, just clicking the stupid button repeatedly, every time with different results... I must be doing something wrong somewhere
$('#btn-copy') .each( function() { clip.glue( this, 'clip_container' ); clip.addEventListener('onMouseDown', function(){ alert('copying... ' + $('#fld').val()); clip.setText($('#fld').val()); }); clip.addEventListener('onComplete', function(){ alert('copied!'); }); }) .click(function() { alert('clicked'); });I am just not able to fully wrap my head around this. I want my two buttons (of equal size): vbbutton.gif and htmlbutton.gif to copy $vbcode and $htmlcode to the clipboard respectively. This is my code so far:
function slicky_links($dirname, $filename, $page) { $imgurl = "http://www.bsfab.net/gallery.php?cmd=midsize&gallery=" . urlencode($dirname) . "&image=" . urlencode($filename); $linkurl = "http://www.bsfab.net/gallery.php?gallery=" . urlencode($dirname) . "&page=" . urlencode($page); $vbcode = '. $linkurl . '?img?' . $imgurl . '/img?/url?'; $htmlcode = "<a href=\\'$linkurl\\'><img src=\\'$imgurl\\' alt=\\'\\' /></a>"; echo "</br><div id=\"clipboard\" style=\"display:inline; padding-top:1px;\"><img src=\"vbbutton.gif\"></div>"; echo " - "; echo "<div id=\"clipboard\" style=\"display:inline; padding-top:1px; \"><img src=\"htmlbutton.gif\"></div>"; }I've got this at another place in the page:
Any advice would be appreciated! Billy
hi
i need a quick help, i am writting a small piece of code so it will adjustable with my clients website.
we are basically having a text with image and both are hyperlink , when user click/mouse over this then a text or code will be copy , and they will navigation to the another url...which actually calls the pop event on complete.
But i cant put the image inside the hyperlink bec i am accesing the code via span
here is my code..
<script language="JavaScript">
ZeroClipboard?.setMoviePath( 'ZeroClipboard?.swf' );
//Create a new clipboard client var clip = new ZeroClipboard?.Client(); clip.setHandCursor( true );//Glue the clipboard client to the last td in each row clip.glue(this);
var url = $(this).attr("href"); //Grab the text from the parent row of the icon var code = $(this).children('span').html(); clip.setText(code);
//Add a complete event to let the user know the text was copied clip.addEventListener('complete', function(client, text) {
});});
<a class="xxx" href="popup.url.php" ><span >FRSDE3RD</span></a> <a class="xxx" href="popup.url.php" ><span >saju</span><img src=""></a> <a class="xxx" href="popup.url.php" ><span >lokesh</span></a> <a class="xxx" href="popup.url.php" ><span >eren</span></a> <a class="xxx" href="popup.url.php" ><span >elf</span></a>
i want to copy the code if i will click on text or image.
firefox 3.6.3 support?
Thank you, Jhuckaby, for a great script.
Hi, I'm working on an extension for Google Chrome, and I'm running into some trouble. I'm 99% certain I've done everything right, yet I can't get the Flash Movie created, let alone have it copy my text.
I should be able to create one ZeroClipboard?.Client(), and it ought to work for multiple elements of equal size, right?
I've tried accessing the .swf file over http:// (through Dropbox), I've tried gluing the movie to only one element, and I've tried copying source code examples from http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/multiple.html. Nothing I've tried has worked.
Is there something inherently difficult or impossible about doing this through a Content Script in a Chrome Extension? Or am I just clueless?
@maddogx93: I have no idea what is involved in making a Chrome extension, but I will say that hosting the ZeroClipboard?.swf on a different domain does seem to work, as in this example:
http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/test-cross-domain.html
I am sorry I cannot help further. Does anyone else know anything about creating Chrome Extensions, and why ZeroClipboard? would not work there?
This may have something to do with the Flash "ExternalInterface?" system that is used to communicate with JavaScript?. It is possible that when running a "Content Script", that Flash has no communication channel with the DOM.
Best of luck, and sorry!
Please add to the navigation links on the instruction wiki page links to the subsections Text to copy, Hand Cursor, CSS Effects, Recommended Implementation (maybe make this title clearer by titling it "placement in relatively positioned container", and all the events onComplete, etc.
Thank you for a great piece of code!
Please advise on how to call the copy method via javascript. I would like to use the existing DOM events associated to HTML objects and not the click event on the flash object.
Unfortunately, it seems like client.setText('sometext'); won't actually put that text on the system clip board. Is it me, or is the only way to copy to clipboard actually clicking on the SWF "glued" to an element?
I've tried this in the base text file:
<input type="button" value="copy" onclick="clip.setText('woot!');alert(clip.clipText);">
That works - it alerts "woot!". However, if I use Ctrl+V in any application, nothing gets pasted. This isn't working in FireFox? or IE. Help! this does
@pfriedl: Flash only allows system clipboard writing when initiated from a mouse click event. The whole idea is, you have to call setText() BEFORE the mouse click. Do it on a mouseDown handler, or better yet a mouseOver. ZeroClipboard? floats an invisible Flash movie on top of your button, intercepts the click event, and thus allows writing the data to the clipboard. But it is your job to get the desired text into Flash BEFORE the click event.
@jhuckaby
So does this mean that I'd need to create a clip fro each button element in my web app to "glue" or instead of using the input's onclick, I use onmousedown instead?
In a nutshell, can I use an "unglued" element like this: <input type="button" value="copy" onmousedown="clip.setText('woot!');alert(clip.clipText);">
Sorry for the confusion, I'm trying to figure out if I can just use one clip and multiple html buttons, or a clip glued to each button.
Thanks for the help!
@pfriedl: There is a way to use one single clip object for multiple buttons, but you have to "move it into place" on each mouseover. Remember, the most important thing is that the Flash movie "intercepts" the click before the browser can get it. So the Flash movie has to be already "under" the mouse when the button goes down. See this example:
http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/multiple.html
Good luck!
@jhuckaby, Ok, that's what I thought. Thanks very much for the info. One more question. Is it possible to programatically fire a click event in the swf?
@pfriedl HAHAHA that's like the number one question I get asked. Unfortunately, no. This is a very strict clause in the Flash 10 security system. In order to write to the user's system clipboard, the code MUST have been started by a real hard mouse click by the user. There is no way to simulate a false click. If there were a way, there would be no need for ZeroClipboard? to exist.
Hi! Im trying to make the content in the flashbutton so that it not only copies the content on the button to the clipboard but also makes it linkable with different links to match the specific flashbutton. for example button containing "microsoft" goes to www.microsoft.com and button containing the text "yahoo" goes to yahoo.com. Is this possible?
HI jhuckaby,
What about CentOS, Linux. I am not able to use it.
1: Implemented code on Windows + Apache -> It works when I check on Windows client. But when I check it on Ubuntu client machine, it stops working
2: Tried uploading this code to one of my CentOS server..... and it does not work there.
What shall I do ....
Hi, is it possible to still have a label on hover for a button that acts as the copy button? Since the flash grabs the hover event, im not seeing the label. Any workaround?
@cor.bosman Well, there isn't a built-in way to provide tooltips, but you have the ability to hook the onMouseOver and onMouseOut events via the ZeroClipboard API, so you can implement your own JavaScript? / DOM tooltip, such as one like qTip ( http://craigsworks.com/projects/qtip/docs/ ). Good luck!
hi, is there a way to change whats on the clipboard other than waiting for the user to click a button? For example, if a user hovers over a cell in a table, I want to automatically put that on the clipboard instead of waiting for the user to click on the cell.
Hi, to make a title (tooltip) appear, you can use something like:
document.getElementById(clip.movieId).title = 'Some title to add';
This will add dinamically a title in the embed ou object created to the flash.
@eitrybuch: You have to create the glue the ZeroClipboard? object BEFORE the click event. You are trying to create the Flash movie too late, after the browser has already handled the click. Don't put any code in a click handler -- try a mouseover handler.
@jhuckaby
sorry, deleted my code, was trying to use thw wikimarkup but can't get it to work :p
here is the code again for everyone else to reference.
@eitrybuch: You have to create the glue the ZeroClipboard?? object BEFORE the click event. You are trying to create the Flash movie too late, after the browser has already handled the click. Don't put any code in a click handler -- try a mouseover handler.
@jhuckaby
I tried moving the new clipboard outside of the click funciton, but it does not work.
You mention the mouseover? How is this accomplished via jQuery?
Thanks for the prompt response.
@eitrynbuch: $j("#uniqueBtn").mouseOver( function() {
http://api.jquery.com/mouseover/
Good luck!
@jhuckaby
Thanks, but 'mouseOver' is not a jquery function but 'mouseover' is ;)
Still not working properly, and still getting the Houdini affect:
Be sure, that #d_clip_container is DIV. You'll have errors, if you'll use P#d_clip_container (or other element excepting DIV).
excuse me
can anybody give an example (for a newbie) to copy text from TEXTAREA to clipboard
thanks
@dtmax1: Thanks, I put the glue on a containter div, the houdini effect is now gone, however the copying is no longer working. I've attached my code:
js:
//Copy to clipboard functionality. This is being triggerd witht he click(); //Create a new clipboard client clip = new ZeroClipboard??.Client(); $j("#uniqueBtn").mouseover(function() { //Glue the clipboard client to the last td in each row clip.glue('uniqueBtn'); //Grab the text from the input value var txt = $j('input#uniqueLink ').val(); //Eventlistener for mouseDown event clip.addEventListener('mouseDown',function(client){ //sets the text that is to be displayed. clip.setText(txt); }) //Add a complete event to let the user know the text was copied clip.addEventListener('complete', function(client, text) { alert('Your Link:\n' + text + '\nwas copied to the clipboard.' ); }); return false; }); //Sets the input to be highlighted when the user clicks inside the in put box. $("input#uniqueLink").focus(function(){ // Select input field contents this.select(); });and the HTML:
<div id="ambassador_right"> <div id="ambassador_unique"> <div class="ambassador_header"> Your Unique Link </div> <!-- ambassador_header --> <div class="ambassador_box"> <label>Your Link:</label> <input type="text" id="uniqueLink" value="<?php print $ambassador['referral_link']; ?>" /> <p> Give the above link to your friends! This is how we'll know they were reffered by you! </p> <div id="uniqueBtn"> <img class="ambassador_btn" src="<?php print url(mySite::themePath());?>/img/ambassador/copy_to_clipboard.png" width="151" height="25" border="0" alt="Copy to Clipboard" /> </div> <div class="clr"></div> </div> <!-- ambassador_box --> </div><!-- ambassador_unique -->and no,
is not commented out, just the way it was pasted in here.
@ jhuckaby: Any thoughts or new ideas?
Thanks in advance everyone.
@eitrybuch: The only thing I can suggest at this point is to use clip.getHTML( WIDTH, HEIGHT ) to get the raw HTML for the Flash movie, and position it in a floating DIV element by yourself. This way you have complete control over how and when the movie is displayed, and can do away with all the glue() silliness (you don't have to call glue() at all). Good luck, and sorry this isn't working for you!
how to copy Rich Text
http://www.rockscrusher.com
@jhuckaby: Well, sorry to hear that we have come to a "dead end". I will keep at it. It's like those ideas/thoughts on the tip of your tongue or back of your head, and you just can't quite formulate them into complete sentences. I'll get it, and when I do I'll post it here to you for you to say, "aha! I told you so!"
Thanks for your replies thus far and keep up the nifty work yourself :)
@love4026: I don't understand, what is at that link?
@jhuckaby: You are not gonna believe this, but the answer to my issues was so simple yet inconceivable. Apparently we both have the same idea of class="hover", and in my css I have .hover{display:none} this is why it was flickering and disappearing!
@eitrybuch Do not pay attention,that's my site. but i want to know how to copy rich text.... I only can copy text with no fornating
@eitrybuch: Glad you figured it out!
@love4026: Read the instructions. ZeroClipboard? supports copying rich text. There is an example on the main page, a test page, and updated instructions how.
For some reason this only works on the 2nd click on the element ZeroClipboard? is glued to. (ZeroClipboard? version 1.0.7 / Firefox 3.6.8 / ExtJS ):
var extwindow = new Ext.Window({ title: 'test', width: 500, height: 500, html: 'test', buttons: [{ text: 'Call clip.setText', id: 'btnTest', handler: function() { clip.setText('sample text'); } }], listeners: { afterlayout: function() { if(clip !== null) { clip.destroy(); } ZeroClipboard.setMoviePath( '/scripts/zeroclipboard/ZeroClipboard.swf' ); clip = new ZeroClipboard.Client(); clip.setHandCursor( true ); clip.glue( Ext.getCmp('btnTest').btnEl.id, 'btnTest' ); } } }); extwindow.show();Any help or direction would be greatly appreciated! Thanks!
@bradbaumann: You are calling clip.setText() too late. You have to call it BEFORE the click. The copy text has to be already set before Flash intercepts the click event. Try setting the text in a mouseOver handler.
Having problem with integrating with ajax <script type="text/javascript" src="ZeroClipboard.js"></script> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript">
</script> When i click in the button it simply says clip is not defined>But i have already included the library.
@gaurabmani: Look at my last reply to the guy just above you. Same answer applies here.
How do I copy text to clipboard sharing is not pressing the button, and when the page loads?
@zloudoktor: Flash can only access the clipboard when the code is initiated from a mouse click event. You cannot copy to the clipboard when the page loads, or at any other time. Doing so would be a terrible thing for a web page to do anyway. Remind me to never visit your website.
I need it not to spread infection, I want to use Flash as a layer=)
@jhuckaby
I don't know if you've solved the positioning issues with glue, but your positioning method is fine. I found that align="middle" in the embed source was throwing off the position a little bit in Firefox. I'm not sure why it throws off the position, but I set align="top", and that fixed my problem right away. Just thought I would post this here so that if other have this problem, it very well could be the align attribute.
Hi,
I have a problem integrating ZC on my intranet. The component is loaded, but this is what I see in firebug :
<div id="box">
</div>Width and height are set to zero ... Maybe this could be a cause : this div belongs to a div(fancybox) with zIndex 1100.
Does anybody have an idea please ?
Thanks in advance. AS
My javascript code, basic as well for testing purposes :
<script language="javascript"> ZeroClipboard?.setMoviePath( 'http://xxx/js/zeroclipboard/ZeroClipboard.swf' ); var clip = new ZeroClipboard?.Client(); clip.setHandCursor(true);
clip.setText( 'plop' ); clip.glue('clicme', 'box');
</script>
@xanadonf: If width and height are zero, then your element is not visible on the page when the glue() function is called. The width and height are pulled from the "offsetWidth" and "offsetHeight" properties of your element, so those must be correct when glue() is called. Try calling the glue() function after the DOM is ready (use a body onLoad, or jQuery ready()).
<script language="javascript"> ZeroClipboard??.setMoviePath( 'http://xxxx/js/zeroclipboard/ZeroClipboard.swf' ); var clip = new ZeroClipboard??.Client(); clip.setHandCursor(true);
clip.setText( 'plop' );
$(document).ready(function() {
}); </script>
I really don't know in which direction investigate :o(
Start removing elements and styles (try removing all your CSS, then put it back in one rule at a time). Something on your page or in your CSS is causing your 'clicme' element to register as zero "offsetWidth" and "offsetHeight". This is usually caused by some parent element set to "display:none" or something. If you cannot figure it out, try using getHTML() instead of glue() and place the raw SWF movie into your own pre-sized floating DOM element with a high z-index by hand. Sorry I don't have time to troubleshoot your site, but good luck!
Is ZeroClipboard? compatible with the lastest version of Flash (10.1.82.76)? I tried using the minimal code possible, but somehow, it's not working:
<script type="text/javascript" src="http://127.0.0.1:6078/zeroclipboard/ZeroClipboard.js"></script> <div id="d_clip_button" style="border:1px solid black; padding:20px; width: 120px;">Copy To Clipboard</div> <script language="JavaScript"> ZeroClipboard.setMoviePath('http://127.0.0.1:6078/zeroclipboard/ZeroClipboard.swf'); var clip = new ZeroClipboard.Client(); clip.setCSSEffects(false); clip.setText("Text was copied!"); clip.glue( 'd_clip_button' ); </script>Currently using Firefox 3.6.8, IE 8;
@awtjdk: Yes, I have Flash 10.1.82.76 and it works fine for me in Firefox 3.6.8, Safari 5.0.1 and Chrome 6.0.472.53. I don't want to boot up VMWare for IE right now, but last I checked it worked there too. Not sure why you are having trouble. Does the official test page work for you? http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/
hey all, I am trying to use this on a project I am working on and I noticed that it is having trouble with Opera 10.62 (I am running win7 64bit).
I am also having trouble with the clip variable.
I declared the variable globally
var clip = new ZeroClipboard?.Client();
and then I have code that writes a message on a div
myMessage = "<a href='Hide this Message' id='hideMessage' onClick=\"$('#msgHolder').hide('fast');return false;\">"; $('#msgDiv').html(myMessage);
but when I add "clip.destroy();" there, it says that clip is undefined
myMessage = "<a href='Hide this Message' id='hideMessage' onClick=\"clip.destroy();$('#msgHolder').hide('fast');return false;\">"; $('#msgDiv').html(myMessage);
any ideas?
Hey good afternoon....
Love the library, just got it working after fighting with ".glue" forever, finally saw the suggestion to go with the ".getHTML" method which works great...
Anyways, onto my question:
I am using ".setText()" to grab some text from a textarea control, it's formatted HTML in there, and using ZC to copy to clipboard and paste into Notepad, I lose all the line breaks....
If I highlight all the text in the textarea and copy to the clipboard and paste into notepad, all the whitespace/line breaks are in place
any suggestions? i know this isn't probably a direct result of ZC, but maybe someone else has run across this
Just to follow up.... using the "10" version of the swf file seems to keep line breaks intact from a textarea
Hello How do I make it deals with more than one item per page? Because it currently does not work, but with only one item I want it works with multiple items
Earlier in these comments Rob says: "This may help some people that experience an issue with Firefox and the flash not being "clickable". Simply add the following to the glue function: style.overflow = 'auto'; "
This can be done in a better way, without messing with the source code. If you want to add another style, you can pass it as an object as a third parameter to the glue function:
var additionalStyles = {
}clip.glue('d_clip_button', 'd_clip_container', additionalStyles);
i am trying to get zeroclipboard to work with wordpress , i am finding it difficult , it does not work at all , the embed code is shown in the firebug , but the button does not work or is clickable , i am try to put the function in the wordpress loop and then getting it to copy the complete content in everypost . please if you can help me out that would be very helpful of you
I am having trouble implementing the ZeroClipboard? library. The testpage works fine, however when I set my version up the movie doesn't seem to be loading and the button is unclickable. This happens even when I copy the example code to my site. Any suggestions as to what the problem may be?
Dear Guys, please please help! First of all that you for beautiful clipboard copier!
I already spent 2 days figuring this out! So broken now. I'm not pro programmer but understand some of it! Please help me to figure out why it only copies text once!? I am sure that I have to destroy() the element and then recreate it in order to fetch dynamically changing link from the flash!
Here is my page: http://ikarate.ru/en-US/photos/
But for me it only works once! So it copies only the first HOVER on it (Copy photos' link to the Clipboard). How do I make it change every time i HOVER on it? In other words how do I destroy() the element PROPERLY so it works:
Here is my script:
Here is the FULL script: http://ikarate.ru/photos/scripts
var clip = null; function $(id) { return document.getElementById(id); } function init() { clip = new ZeroClipboard.Client(); clip.setHandCursor( true ); clip.addEventListener('mouseOver', function (client) { // update the text on mouse over clip.setText(slideURLsharemylink); }); clip.glue( 'video_url_copy' ); } if(clip != null) { clip.destroy(); } init(); }Here is my page please please help me to finish it! http://ikarate.ru/en-US/photos/
Other shares (Facebook, Twitter and Google works fine with EACH every photo showing)
Thanks,
Best regards to all!
Ok, I think I got the problem! Is there a way to have clipText updated within the same client id? I mean, that my value is URL, that always changing, as the gallery plays a new photo? I have one button for "Copy to Clipboard" with one clip.glue id? Is this possible to make ZeroClipboard? update clipText everytime I click on my button?
What is happening now - it works once, as supposed to! But when I click second time, nowthing is rerecorded into clipboard, because the element is already created?
Does anyone know if it is possible to force the copy function without clicking a button? (I would like to trigger the copy onMouseOver)
Hii All. Thanks for the ZeroClipBoard?.There is one problem for me. I need to do it with Actionscript 2.0. I want to attach this to a button that should copy the text continuously after the button is clicked. Basically in Firefox the timer function is not working. I need it urgent, Please do have your suggestions. Thanks in advance.
Hi thanks for this wonderful tool. it made my life a lot easier.
I am having some issue with ajax call and multiple elements.
everything copies OK when the page is first loaded, but when ajax calls the page and it has updated its content, zeroclipboard will still copy, but its copying the old data.. I initially thought it to be a browser cache issue, but all my attempt to correct that has yielded no result. I have done the following:
1. adding header no-cache 2. appending random number to url so browsers think its a new page. ?i=math.random();
Here is the portion of my code that is relevant.
index.php
<script language="JavaScript"> var clip = null; function init() { // setup single ZeroClipboard object for all our elements clip = new ZeroClipboard.Client(); clip.setHandCursor( true ); // assign a common mouseover function for all elements using jQuery $('div.multiple').mouseover( function() { // set the clip text to our innerHTML clip.setText( this.innerHTML ); // reposition the movie over our element // or create it if this is the first time if (clip.div) { clip.receiveEvent('mouseout', null); clip.reposition(this); } else clip.glue(this); // gotta force these events due to the Flash movie // moving all around. This insures the CSS effects // are properly updated. clip.receiveEvent('mouseover', null); } ); } </script>currentgames.php <-- index.php?p=currentgames
I have my ajax functions here to display the current games, and want the users to be able to copy the gamename. This page makes ajax call to getGames.php every 10 seconds.
getGames.php
any help is greatly appreciated. a live example can been seen here: http://www.dotacash.com/index.php?p=currentgames
I forgot to add that at the end of getGames.php is where i call the init function
HEllo i configured it near about final on wordpress but here is a problem that when i am putting a long html code it's not working So please tell me how to put long html code between the selected area to be copied.
Thanks
I want the d_clip_button to also submit to a form (it activates an app that uses the clipboard info). There seems to be no working way to integrate form and standard submit tags into the DIV area that comprises the d_clip_button. Should I be trying to edit the movie to get this functionality?
Thanks in advance for any help. :)
It there a way to determinate if flash is available within ZeroClipboard??
Thank you "ZeroClipboard?", Keep going,
God Bless You! \o/
Thanks a lot for this work around, have got this working a treat with FF / Chrome / Safari, only issues I found was with non-flash devices, however this can be expected. Easy fix for this with browser detection
I want the d_clip_button to also submit to a form Yufeng is a professional mining equipment manufacturer and exporter. We have a team of high quality research experts who have always been providing best crushing plant solutions for our customers. For more than 20 years, apart from crusher, we have provided with grinding mill ,stone crusher and jaw crusher etc.Site: http://www.crusherland.com/ http://www.yfballmill.com/
First I must say I really like the code. I am trying to implement the code to allow multiple different buttons on the page. The odd thing is it is working perfectly in IE. However in FF the buttons work on initial display, but if you scroll the page, the buttons no longer work. However, if you scroll, minimize then maximize, or reload, or swap windows the buttons work. I am sure this is due to positioning. I am using the nested div technique described above for positioning, i.e. d_clip_container then d_clip_button. Any ideas for a fix?
is there any way to clear the clipboard automatically?
To clear couldn't you just clip.setText(""); or clip.destroy() then rebuild?
This is a follow up. Has anyone experienced a problem in FireFox? with not being able to click the div to copy after the div has moved due to scrolling? I am using the nested div example above, for example d_clip_container then d_clip_button. When the page loads everything is fine. When you scroll the page the div is no longer clickable. If you swap windows or minimize then maximize then the divs are clickable.
Another follow up. I have corrected the problem of not being able to click the div after scrolling.
Great code - thanks.
A small query - I'm using ZeroClipboard? to allow folk to copy dynamically created URLs to specific pages in a project. The copying action is converting the "&" character in those URLs to its & form - is there any way to block or back-convert this action?
There appears to be a complete lack of keyboard access. Which is a rather a deal breaker. Or have I missed something? This probably needs control of movie position in tab order (replace item when glued) and responding to key events to cause the copy.
Is there any way to use ZeroClipboard? by click on the checkbox? Click on checkbox -> copy title to clipboard and checkbox marked V.
Is there is any way to use ZeroClipboard? to:
Hi there!
I have an html table, from which I want to copy rows (the user can select which rows, by checkboxes). How can I create a button, that will copy the generated html code to the clipboard? Currently I can only do this, with pressing my button with the html creator code, and then pressing the copy to clipboard button. Is there anyway to connect these two?
Thanks
Hi,
I want to use this script... but I need to run a javascript that would send data to the clipboard every second as "" (i.e. keep the clipboard clear... the general idea is to prevent the use of Print Screen).
Is it possible to do this with this script? And if so, can it be done without showing any extra stuff on the page?
Thanks
first of all, thanks for this wonderful script but i have a problem with it.
The site I am working on changed the 'share' button to a modal window (jquery blockUI) and i can't seem to get this to work.
I have read that this may be because of the z-index issue but I am not sure.
Can someone enlighten me if this is possible (making zero clipboard work with a modal window created by blockui)?
thanks.
found the solution to my question. To permanently change the z-index of the zero clipboard script, look for the code
var zIndex = 99;
and i replace it with
var zIndex = 1100; //blockui uses z-index: 1000
and it fixed the problem
hope this helps other people too
"However in FF the buttons work on initial display, but if you scroll the page, the buttons no longer work. However, if you scroll, minimize then maximize, or reload, or swap windows the buttons work."
I have the same problem. The demo (http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/) have this too. Any solution?
Hi,
Can anyone tell me how to edit the code so that I can achieve the following?
I would like to have a simple html link that says "click here". When someone clicks that link a 4 letter string of text would be copied to the clipboard and a webpage would open?
Thanks,
Rob
Hello there,
First of all, BIG thanks for your script, it's great. My question is: how can I get ZeroClipboard? to copy text from TWO fields at the same time, and have these two values separated by e.g. a semicolon when I paste them?
Many thanks,
Joël
Works great, thanks for all your work!
For what it's worth, I ran into the 0 width/height problem as well. Same problem as xanadonf, I'm attaching to a button loaded in a initially-hidden modal dialog. Maybe worth a mention in the docs? getHTML() worked perfectly.
I am working on getting Zero Clipboard to work on a jQuery ToolTip?. Using the documetation's basic example works anywhere on my page except when I place it in my tooltip's markup. I am looking into getHTML but am having a hard time finding examples of how to use it in the script using document.write Does anyone know of a good example?
Thanks
Mark
lol
After fighting with this approach for a day I think I must give up. The whole approach is both overwhelmingly complex for a simple task and too simplistic for more demanding ones. I think that the whole JS (and possibly the AS3) side has to be heavily modified or possibly rewritten to make it work in more complex situations with dynamically movable, creatable/hideable/showable containers etc.
The "glue" div, for instance is glued in an absolute position. Let's see: a jquery.draggable container that originally contained the "glued" button is dragged to a new place. The position of the button does not match the original button/control any more. It took me two hours to find out this whereafter I simply gave up.
I still keep using the idea in simple pages and popups but with heavily dynamic Ajax/DHTML applications this is definitely not an option.
What I would like to achieve is as follows:
- Initialize a SINGLETON flash control using a JS API with NO JS callbacks needed - Press a button -> call a js function "copysmthng()" - Use simple JS API to move the text to the flash control's storage - Use simple JS API to tell the flash control to move the stuff to clipboard
And all this WITHOUT a mandatory JS callback creation.
I think this is what most developers need. Can it be achieved without the weird "glue" approach?
Markku
i followed by somebody's tps. but it can't work,
<pre> I added a tooltip to the object by doing the following.
Line 90 of the ZeroClipboard?.js file.
handlers: null, // user event handlers added -> toolTip: 'Copy to Clipboard',
at Line 108:
this.div = document.createElement('div'); added -> this.div.title = this.toolTip;
Simple Enough. :-) </pre> what's wrong with it?
trouble with using ZeroClipboard?? and add a tooltip: 'm trying to use Zeroclipboard to copy stuff to the clipboard and add a tooltip when the mouse hover on the flash. but it doesn't seem to be working. my html code:
My js code: i have added the jquery library.
ZeroClipboard?.setMoviePath("http://example.com/js/ZeroClipboard.swf"); var clip = null; var url = ''; function init() { clip = new ZeroClipboard?.Client(); clip.setHandCursor( true ); $('.cptext').mouseover( function() { clip.setText(this.innerHTML); $('.test').css("display","block"); if (clip.div) { clip.receiveEvent('mouseout', null); clip.reposition(this); } else { clip.glue(this); } clip.receiveEvent('mouseover', null); url = $(this).attr('rel'); }); clip.addEventListener('mouseUp', function(client) { window.open(url); }); clip.addEventListener('mouseOut', function (client) { $('.test').css("display","none"); }); } $(document).ready(function() { init(); });why my code can't work.expect someone can help me/ many thanks
Possible tooltip conflict fix:
clip.addEventListener( 'mouseOver', function(client) { $('.tooltip').show(); }); clip.addEventListener( 'mouseOut', function(client) { $('.tooltip').hide(); }); clip.addEventListener( 'mouseDown', function(client) { $(".tooltip_text").replaceWith('<div class=\"tooltip_text\">Text copied!</div>'); });I can confirm it works on Mac in Chrome
"Your browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit?/534.24 (KHTML, like Gecko) Chrome/11.0.696.71 Safari/534.24"
I have a rather complex UI. Unfortunately, zeroclipboard positions the flash movie at a totally wrong place on the screen. Checking with Firebug, you can see that it is hundreds of pixels off its intended location.
Has anyone seen this behaviour before?
I solved my problem with the positioning by doing it without the glue function but "manually" as described here: http://code.google.com/p/zeroclipboard/issues/detail?id=26
This is mighty instable for me:
It works on 64bit Ubuntu 10.10 with Firefox 4
On the same machine, it works in Chrome 12, but not the event handlers that simulate the hover effect
On a Mac, nothing works (Firefox, Chrome)
Is it possible to set a default text to the clipboard using Javascript? For example, if you refresh the page using refresh button, would it be possible to have clipboard "page refreshed" text in there after reloading?
very nice.
Any one want to use the element title, should try this: if(clip.div) {
}If the container (d_clip_container in the example) has a relative position, giving left:0 and top:0 to the button works, after resizing window too ... I've change the ZeroClipboard??.js (line 121)
Just spent hours trying to get this to work in IE (works fine in Chrome and FF). Figured out it has to do with the DOM issue "project member" mentioned on April 2nd, 2009. However, the suggested fix didn't work, and like others have noted it has problems anyways.
So my solution is to wrap all the ZeroClipboard? code in a function and then call that function directly in the BODY ONLOAD of the webpage.
Also, use container DIVs like suggested!
I would like to know whether Flash is installed or not. Is there a function to return that?
Hi, this is what I tried:
<html xmlns="http://www.w3.org/1999/xhtml">
</html>
I did this, because I have several hidden input fields, and I just want to copy a precise String that I (the webmaster) decide! So, onclick event on input button, should copy the value of the hidden input field. Any ideas on how to make it work in that way?
Many thanks
No way to get an answer??
very good !
This is a function that will return the Flash version if installed, otherwise it returns '0'. I'm not the author. Although, I have tested in IE, FF and Opera. I believe it is what it was asked for. If any question marks appear as hyperlinks, they should be removed from the code, except the ones from inside RegExps?.
// function getFlashVersion()
{
}//
Hi Thx for this nice code. I'm trying to use ZC with a Javscript Framework application (Wavemaker) which makes it very difficult to embed. Is there a way to use ZC by passing the stuff to copy as direct parameter to zeroclipboard.js script ? I would need to not have to make the user click on anything. Thanks. Tom
I'm having trouble making the demo run from disk. I give details in Issue #85 (http://code.google.com/p/zeroclipboard/issues/detail?id=85).
What am I missing? Why does it work from the test page on this site, but not running from the test.html file opened from disk? Thanks, Rich.
I need to copy to the clipboard when pressed ctrl + c var isCtrl = false;
may be I can simulate (button.click)? like this: JS? <html>
[/JS] but... it does not work:(
I'm having some problem getting ZeroClipboard? working when the div with the textarea & #d_clip_button button is initially set to display:none.
You can see the example here: http://jephchristoff.com/index/zeroclipboard.html
Any workaround for this would be awesome.
my site http://www.crusherline.com content also don-t copy with others, how can i do
THX a lot! Will implement your piece of code for sure. Best wishes!
I have multiple instances of the 'copy to clipboard' hidden div. I'd like to hide or destroy them as well, but in both hide() and destroy() they use "this.div" which is the hidden flash div. Is there a way to find this in the html if I give it an 'id'?
So I can find one specifically and hide it? (using jquery like document.getElementById('hidden1);) (In glue function I would have an id attribute like hidden1. )
Is this on the right path? Are there other solutions to having multiple instances of clip and removing each randomly?
Thanks! I'd really appreciate help!
Not sure of your exact solution but you do understand that in var clip = new ZeroClipboard?.Client();
clip should be a unique identifier? Thus, do not recycle clip for each ZeroClipboard? client you want to create. 'glue()' also creates new ZeroClipboard? divs (bug). Thus, what I am getting at is you can destroy 'random' clips by:
var clip0 = new ZeroClipboard?.Client(); var clip1 = new ZeroClipboard?.Client(); var clip2 = new ZeroClipboard?.Client(); var clip3 = new ZeroClipboard?.Client(); var clip4 = new ZeroClipboard?.Client();
clip0.destroy(); clip2.destroy(); clip4.destroy();
Be more creative in your data structures, though.