index.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>test</title>
  6. </head>
  7. <body>
  8. <input type="text" id="data" value="测试数据">
  9. <button id="copy">复制</button>
  10. <button id="cut">剪切</button>
  11. <!--[if IE]>
  12. <button id="paste">粘贴</button>
  13. <![endif]-->
  14. <script src="../clipBoard.min.js"></script>
  15. <script>
  16. /**
  17. * 复制、剪切:chrome、Firefox、ie
  18. * 粘贴:ie
  19. * @date 2016-04-25
  20. * @return {[type]} [description]
  21. */
  22. document.getElementById('copy').onclick = function() {
  23. var test = new clipBoard(document.getElementById('data'), {
  24. beforeCopy: function() {
  25. },
  26. copy: function() {
  27. return document.getElementById('data').value;
  28. },
  29. afterCopy: function() {
  30. }
  31. });
  32. };
  33. document.getElementById('cut').onclick = function() {
  34. var test = new clipBoard(document.getElementById('data'), {});
  35. test.cut();
  36. };
  37. document.getElementById('paste').onclick = function() {
  38. var a = new clipBoard(document.getElementById('data'), {});
  39. a.paste();
  40. };
  41. </script>
  42. </body>
  43. </html>