1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>test</title>
- </head>
- <body>
- <input type="text" id="data" value="测试数据">
- <button id="copy">复制</button>
- <button id="cut">剪切</button>
- <!--[if IE]>
- <button id="paste">粘贴</button>
- <![endif]-->
- <script src="../clipBoard.min.js"></script>
- <script>
- /**
- * 复制、剪切:chrome、Firefox、ie
- * 粘贴:ie
- * @date 2016-04-25
- * @return {[type]} [description]
- */
- document.getElementById('copy').onclick = function() {
- var test = new clipBoard(document.getElementById('data'), {
- beforeCopy: function() {
- },
- copy: function() {
- return document.getElementById('data').value;
- },
- afterCopy: function() {
- }
- });
- };
- document.getElementById('cut').onclick = function() {
- var test = new clipBoard(document.getElementById('data'), {});
- test.cut();
- };
- document.getElementById('paste').onclick = function() {
- var a = new clipBoard(document.getElementById('data'), {});
- a.paste();
- };
- </script>
- </body>
- </html>
|