Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.
Note: This page documents the Jetpack Prototype, which is  no longer under active development. Read the experiment report for what we learned from it and the blog post announcing the first SDK release for what we're up to next!

Jetpack's clipboard support API provides a standardized way for features to access the clipboard. Features can get and set the clipboard in various flavors of data type.

The namespace associated with this API is jetpack.clipboard which provides both read and write access to the clipboard. The API is fairly straightforward; examples can be found here.

The API lives in the future and must be imported for use.

jetpack.future.import("clipboard");

Methods

set(contentstringflavorstring) stringWrites data from Jetpack to the clipboard. This is the recommended method of copying data to the clipboard.
contentThe content to be copied to the clipboard. If no other arguments are specified, the flavor of the content is assumed to 'plain'.string
flavorData type. This is an optional parameter. The only flavors currently implemented are 'plain' (text/unicode) and 'html' (which is HTML).string"text"

Here's an example of how to use the method to set the clipboard.

jetpack.import.future("clipboard");
// In text format
jetpack.clipboard.set("Hello World");
// In other clipboard
get(flavor string)Returns data to Jetpack from the clipboard. If flavor is provided, the data is returned in that format.
flavorReturns data to Jetpack from the clipboard. If flavor is provided, the data is returned in that format. string

Here's an example of how to use the method to get the data on the clipboard. Remember to import clipboard from the future before calling it.

jetpack.import.future("clipboard");
var myContent = "<i>This is some italic text</i>";
jetpack.clipboard.set( myContent, "html" );
getCurrentFlavors()Returns an array of available Jetpack clipboard flavors, for the current system clipboard state.
jetpack.import.future("clipboard");

var myContent = "<i>This is some italic text</i>";
jetpack.clipboard.set( myContent, "html" );

var flavs = jetpack.clipboard.getClipboardFlavors();
// Should equal ["html", "text"]
console.log( flavs );

Document Tags and Contributors

 Contributors to this page: Sheppy, MykMelez, JetpackBot, rlph, Aza, fiveinchpixie, adw
 Last updated by: Sheppy,