JS copies to clipboard, compatible with Firefox and IE

Source: Internet
Author: User

In web development, the copy to clipboard function is often implemented. This function is very practical, but due to security issues, browser restrictions become increasingly strict, and the implementation methods become increasingly limited. By default, Firefox cannot directly operate the clipboard using JavaScript. You must enable relevant settings. It is impossible to achieve cross-browser clipboard only through javascript technology. Currently, the common advantage is to use javascript‑flash flash, and the general stream processing method is _clipboard.swf, which is the earliest implementation in foreign countries (the famous clipboard copy solution: http://www.jeffothy.com/weblog/clipboard-copy ). However, it is very feasible. _clipboard.swf is invalid in the new flash10, because flash10 specifies that the clipboard can be started only after actual operations (such as mouse clicking) are performed on the SWF. The SwF of the _clipboard.swf method is hidden. You can use JavaScript to operate the flash clipboard. Obviously, no actual user operation is performed on the SWF.

To address this problem, a new method has recently emerged outside China, and a javascript library zero clipboard has been built specifically. It contains a Flash video and a javascript interface, this flash is transparent (not hidden) and users will not notice its existence. This flash is covered by a DOM element, such as a button or Div. When you click this Dom, you actually click this flash, this action on flash can enable the flash clipboard. This is actually a clickjacking.

Demo page: http://bowser.macminicolo.net /~ Jhuckaby/zeroclipboard/

Zero clipboard project home: http://code.google.com/p/zeroclipboard/

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.