Zeroclipboard Copy to clipboard Chinese document

Source: Internet
Author: User

Loading JavaScript files using methods
<script src="ZeroClipboard.js"></script>
If the zeroclipboard.swf is not in the same directory as the page, you can set a path
Zeroclipboard.setdefaults ( {     '/path/zeroclipboard.swf ' });    //  var clip=New Zeroclipboard (document.getElementById ("Copy-button"), {     '/path/zeroclipboard.swf '
Call

You can pass an element or an array of elements. (Here's how jQuery gets the elements)

var clip=new  
Amd

If you use Requirejs, Curl.js, Seajs and other AMD-spec module loaders, you need to set the module ID or path value to Amdmoduleid to use zeroclipboard normally. Cases:

function (zeroclipboard) {     zeroclipboard.setdefaults ({         ' Path/to/zero-clipboard '     }) ;
or set the path, requirejs example:
requirejs.config ({     paths:{         "Zeroclipboard": "Path/to/zero-clipboard"     }});  define (["Zeroclipboard"],function(zeroclipboard) {     zeroclipboard.setdefaults ({         ' Zeroclipboard '     }); });
Parameter description
New Zeroclipboard (elements [, options])
Options parameter Description
name Default Value Description
Swfpath "Zeroclipboard.swf" Flash file path, the default SWF file path is the same as Zeroclipboard.js
Trusteddomains Window.location.host? [Window.location.host]: [] A trusted domain (an array of strings or strings)
Cachebust True
Forceenhancedclipboard False
Flashloadtimeout 30000 The time-out period for loading Flash, if not required, can be set to 0. Unit (MS)
AutoActivate True
Bubbleevents True
Containerid "Global-zeroclipboard-html-bridge"
Containerclass "Global-zeroclipboard-container"
Swfobjectid "Global-zeroclipboard-flash-bridge"
Hoverclass "Zeroclipboard-is-hover" The class added to the element when the mouse is moved
Activeclass "Zeroclipboard-is-active" Selected is the Class that adds to the element
Forcehandcursor False
Title Null
ZIndex 999999999
Considerations for parameter allowScriptAccess options

1.1.7 and the following versions, the default value for allowScriptAccess is always. means allowing "zeroclipboard.swf" files to be hosted by other domains. In order to improve security, the allowScriptAccess default value for 1.1.7 is Samedomain, allowing only "zeroclipboard.swf" under the same domain.

If you are upgrading from 1.1.7 or lower to 1.1.7 or later, you need to save "zeroclipboard.swf" to the same domain, or set the value of allowScriptAccess to always.

For more information about allowscriptaccess, you can refer to the official documentation.

Data Property

name Description
Data-clipboard-target The element ID. After you find the element, try to copy the value of the . Value or. textcontent or . InnerText of the element.
Data-clipboard-text The content that is copied by default.

When you set both data-clipboard-target and data-clipboard-text two properties, only the value of Clipboard-target cannot be found Clipboard-text

Clipboard-text is not selected even if the value obtained to Clipboard-target is empty

API methods
name Description
Glue (DOM) Binding to an element
Reposition () Adjust position
On ("Event", My_load_handler) Binding events
Off ("Event", My_load_handler) Canceling an already-bound event
Event

Using the API's method on () to bind

name Example Description
Load Clip.on ("Load", function (Client,args) {...}); event when the Flash load is complete. The args parameter contains the following properties:

Flashversion: The version number of the current Flash

MouseOver Clip.on ("MouseOver", function (Client,args) {...}); The event when the mouse is moved. The args parameter contains the following properties:

Flashversion: The version number of the current Flash

Altkey: Hold down the ALT key

Ctrlkey: Hold down the CTRL key

Shiftkey: Hold down the Shift key

Mouseout Clip.on ("Mouseout", function (Client,args) {...}); The event when the mouse is moved out. The args parameter contains the following properties:

Flashversion: The version number of the current Flash

Altkey: Hold down the ALT key

Ctrlkey: Hold down the CTRL key

Shiftkey: Hold down the Shift key

MouseDown Clip.on ("MouseDown", function (Client,args) {...}); The event when the mouse is pressed. The args parameter contains the following properties:

Flashversion: The version number of the current Flash

Altkey: Hold down the ALT key

Ctrlkey: Hold down the CTRL key

Shiftkey: Hold down the Shift key

MouseUp Clip.on ("MouseUp", function (Client,args) {...}); The event when the mouse bounces. The args parameter contains the following properties:

Flashversion: The version number of the current Flash

Altkey: Hold down the ALT key

Ctrlkey: Hold down the CTRL key

Shiftkey: Hold down the Shift key

Complete Clip.on ("Complete", function (Client,args) {...}); The event when the content was successfully copied. The args parameter contains the following properties:

Flashversion: The version number of the current Flash

Altkey: Hold down the ALT key

Ctrlkey: Hold down the CTRL key

Shiftkey: Hold down the Shift key

Text: Copied content

Noflash Clip.on ("Noflash", function (Client,args) {...}); No Flash events are detected.
Wrongflash Clip.on ("Wrongflash", function (Client,args) {...}); Events when the Flash version is below the required version. Zeroclipboard requires Flash 10.0.0 or more versions.
datarequested Clip.on ("datarequested", function (Client,args) {...}); Event at start of replication
Related information

Zeroclipboard Copy to clipboard Chinese document

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.