JavaScript to implement the copy and paste Functions

Source: Internet
Author: User

JS implements the copy and paste functions. The following simple code can only implement the copy function in IE, and the test is no problem in IE browser. But Firefox cannot. The sample code is as follows:

The html code is as follows:

<Input type = "text" id = "copyFromTxt"/> <input type = "button" id = "copyBtn" value = "copy"/> <input type = "button" id = "pasteBtn" value = "paste"/> <input type = "text" id = "copyToTxt"/>

The JS Code is as follows:

$ (Function () {$ ('# copyBtn '). click (function () {window. clipboardData. setData ('text', $ ('# copyFromTxt '). val () ;}); $ ('# pasteBtn '). click (function () {$ ('# copyToTxt '). val (window. clipboardData. getData ('text '));});});
Articles you may be interested in
  • Run the code preview code, save the code as, and copy the implementation of the code function.
  • Prohibit web page right-click, copy, save as, View Source file and other functions to implement web page source code protection
  • JavaScript copy function code, compatible with multiple browsers
  • Image zoom-in display special effects slimbox the most lightweight function the most powerful Jquery Image zoom-in special effects
  • Copy a webpage and add copyright information automatically
  • How to optimize servers, static databases, and load balancing for high-traffic websites
  • Google blog search enables the ping function to enable real-time indexing of website content
  • Php's function of limiting file download speeds

Related Article

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.