Connect with me
Search
Tags
Twitter Feed
Navigation
« Getting the physical folder path of a virtual path or directory in WCF | Main | datejs - the javascript date library that will let you work with dates like a ninja »
Monday
Jan252010

Cross Browser Copy and Paste - with ZeroClipboard *updated*

I previously wrote about a cross browser copy and paste using jQuery.Copy. Everything was fine until flash updated to version 10. It now throws a security warning. Jojo pointed out that were was another plugin using the same concept that avoids this security warning. Enter Zero Clipboard The implementation is simple:

Step 1 - Include ZeroClipboard.js & ZeroClipboard.swf

Include ZeroClipboard.js in your header scripts. After the script, set the path of the ZeroClipboard.swf flash file.

<head>
	...
	<script type="text/javascript" src="/scripts/ZeroClipboard.js"></script>
</head>

<script type="text/javascript">
	ZeroClipboard.setMoviePath('/scripts/ZeroClipboard.swf');
</script>

Step 2 - Start using it!

ZeroClipboard allows you to create multiple instances of the clipboard. In most circumstances you will only need one. Instantiate the clipboard and then start using it.

	var clip = new ZeroClipboard.Client();

	// Copy some text
	clip.setText("Hello World");

There’s a lot more you can do with this little script and you can find out more from their wiki

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>