Home > Web Front-end > JS Tutorial > JS implements cut, copy and paste based on clipBoard.js plug-in_javascript skills

JS implements cut, copy and paste based on clipBoard.js plug-in_javascript skills

WBOY
Release: 2016-05-16 15:02:49
Original
1370 people have browsed it

Summary:

I recently worked on a project, in which there was such a requirement: to implement a function of clicking a button to copy a link. I searched for relevant information on the Internet and found several plug-ins. ZeroClipboard is a copy function implemented through flash. As more and more people Many people proposed to abolish flash, so I wondered if copying and cutting could be achieved through js?

Address: https://github.com/baixuexiyang/clipBoard.js

Method:

Copy

var copy = new clipBoard(document.getElementById('data'), {
beforeCopy: function() {
},
copy: function() {
return document.getElementById('data').value;
},
afterCopy: function() {
}
}); 
Copy after login

Cut

var cut = new clipBoard(document.getElementById('data'), {
beforeCut: function() {
},
Cut: function() {
return document.getElementById('data').value;
},
afterCut: function() {
}
});
Copy after login

Paste

var paste = new clipBoard(document.getElementById('data'), {
beforePaste: function() {
},
paste: function() {
return document.getElementById('data').value;
},
afterPaste: function() {
}
});
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template