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