Home >Web Front-end >JS Tutorial >Copy to clipboard in GWT js flash implements copying with better compatibility_javascript skills
But you can copy it using flash. An example is VeryCd. Look at the "Copy selected connection" button which is a flash. It seems that flash’s security sandbox does not restrict copying content to the clipboard
But there are limitations:
1 According to the folks at ZeroClipborad, these flashes must be loaded over the network.
Zero Clipboard Does Not Work From Local Disk
This is a security restriction by Adobe Flash Player. Unfortunately, since we are utilizing the JavaScript-to-Flash interface ("ExternalInterface ") this only works while truly online (if the page URL starts with "http://" or "https://") . It won't work running from a local file on disk.
However, there is a way for you to edit your local Flash Player security settings and allow this. Go to this website:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html
And add the path to your local "ZeroClipboard.swf" file to the trusted files list, or try the "allow all" option.
2 Although flash provides a copy function, it only requires one click from the user. This means that you cannot copy to the clipboard through the setText function in JavaScript. Instead, after calling the setText function, the user's mouse clicks on the flash.
This library is fully compatible with Flash Player 10, which requires that the clipboard copy operation be initiated by a user click event inside the Flash movie.
This has the same problem as swfupload that uses flash to upload files.
Using ZeroClipboard, you can copy web content to the clipboard. However, ZeroClipboard does not have GWT encapsulation. Our project uses GWT, so we learned from swfupload's GWT encapsulation and encapsulated ZeroClipboard into a form that can be called by GWT.
1 First encapsulate a zeroclipboard.jar
2 The GXT control library is used in the project. In order to closely integrate with the control, I wrote a ZClipboardBinder class to combine the two
3 The usage method is shown below (Zeroclipboard_test.java)
onModuleLoad()
. Relevant downloads are in the attachment.
Showing the result
After clicking the button - you actually clicked on the flash above. Use ctrl v to see the result.
Now I find that there are many meaningful functions that cannot be implemented with JavaScript, such as uploading multiple files and copying to the clipboard, which are all implemented through flash as an intermediary and "curve". I don't know the final HTML5 There is no need for us to dwell on whether these problems have been solved.
Zero Clipboard open source JavaScript flash copy library class