How to make HTML5 to achieve mobile replication

This article mainly introduces how to make HTML5 to achieve mobile replication functions, have a reference value, and friends needed can be referred to. I hope that everyone has a big gain after reading this article. Let’s take a look at you with everyone.

First encountering this demand is a variety of Baidu, but it is found to be implemented in JS, and the compatibility is very bad.

But in the process of finding and trying, it is found that only the CSS code can be fully implemented. You can add the following line of code to the following line of the label that needs to copy content.

–Webkit-Touch-Callout: all; -webkit-user-select: all; -moz-user-select: all; -ms-user-select: all; user- SELECT: ALL;
  It is, that is, the user does not limit the operation of the content, without the system default menu, long press display system comes with the replication function of the system.  
Use clipboard.js to implement mobile paste replication

clipboard.js is a very powerful paste copy, but is used in mobile terminals, compatible Sexual problem. Below is a solution I often use.



$ (Function () {var clipboard = new clipboard ('. Btn'); // Elegant downgrade: Safari version number> = 10, prompt copying success; otherwise prompts need to be selected After the "copy" is manually selected to copy Clipboard.on ('Success', Function (E) {Alert ('copy success!') Console.log ($ (this)) E.CLEARSELECTION ();}); clipboard.on ('error', function (e) {Alert ('Please select "Copy" to copy! ')});})
Note that I use the INPUT control when saving the content to be copied, not P or SPAN. Because, only INPUT is best compatible during testing, there is no problem, and it can guarantee normal replication. At the same time, the plugin does not support Safari version number

Thank you for reading this article carefully, I hope that how to make HTML5 to achieve mobile replication function content, and I hope everyone will support it. TUMI cloud, pay attention to Tumi cloud industry information channel, find TUMI clouds, detailed solutions are waiting for you!

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment