Labs/Jetpack/JEP/10: Difference between revisions

Line 25: Line 25:
<pre class="brush:js;toolbar:false;">jetpack.os.clipboard.set( data, [dataType] )</pre>
<pre class="brush:js;toolbar:false;">jetpack.os.clipboard.set( data, [dataType] )</pre>


The <code>data</code> paramater can be anything, a string, a unicode string, a number, an image, and HTML fragment, etc. that you want to place in the system clipboard. The optional <code>dataType</code> let's Jetpack know what kind of data is being passed in, in mime-type format. For example, a unicode string would take <code>"text/unicode"</code>, HTML would be <code>"text/html"</code>, and an PNG would be <code>"image/png"</code>.
The <code>data</code> paramater can be anything, a string, a unicode string, a number, an image, and HTML fragment, etc. that you want to place in the system clipboard.
 
The optional <code>dataType</code> let's Jetpack know what kind of data is being passed in, in mime-type format. For example, a unicode string would take <code>"text/unicode"</code>, HTML would be <code>"text/html"</code>, and an PNG would be <code>"image/png"</code>. If <code>dataType</code> isn't passed in, Jetpack makes it's best guess.
 
An example of setting the clipboard in action is as follows:
 
<pre class="brush:js;">var html = "<div>Hello <i>there!</i></div>";
jetpack.os.clipboard.set( html, "text/html" );
 
var words = "The quick brown fox jumped over the lazy dog.";
jetpack.os.clipboard.set( words );
</pre>
577

edits