zeroclipboard flash_javascript trick to copy to clipboard
WBOY
Release: 2016-05-16 18:21:59
Original
1029 people have browsed it
The following are the implementation steps: 1- Reference files. After downloading, you will get two core files, ZeroClipboard.js and ZeroClipboard.swf, reference one of them in the project.
2- Loading ZeroClipboard object and implements the copy function.
//This step is very important, set the flash file reference path. ZeroClipboard.setMoviePath('http://www.cnblogs.com/Scripts/ZeroClipboard/ZeroClipboard.swf'); //Create ZeroClipboard object clip = new ZeroClipboard.Client(); clip.setHandCursor(true); //Loading event, in the mouseOver event, transfer the content to be copied to the flahs file and save it clip.addEventListener('mouseOver', function(client) { clip.setText($('#IndInfo').val()); }); //A dialog box will pop up after successful copying clip.addEventListener('complete', function(client, text ) { alert("Copied text to clipboard:nn" text); }); //Specify the object that implements the copy function clip.glue('Copy'); / /The following is the html object used <%= Html.Hidden("IndInfo", ViewData["IndInfoFormat"].SafeString())%>
3- If it is local debugging, flash-based security mechanism requires some settings http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html Just enter the physical path of the flash file directly on the web page.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn