码迷,mamicode.com
首页 > Web开发 > 详细

js实现剪切、复制、粘贴——clipBoard.js

时间:2016-05-03 09:19:40      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

摘要:

  最近项目上要实现一个点击按钮复制链接的功能,刚开始查找了一些资料,找了几款插件,ZeroClipboard是通过flash实现的复制功能,随着越来越多的提议废除flash,于是就想能不能通过js来实现复制剪切呢?

地址:https://github.com/baixuexiyang/clipBoard.js

方法:

复制

var copy = new clipBoard(document.getElementById(‘data‘), {
    beforeCopy: function() {

    },
    copy: function() {
        return document.getElementById(‘data‘).value;
    },
    afterCopy: function() {

    }
});

剪切

var cut = new clipBoard(document.getElementById(‘data‘), {
    beforeCut: function() {

    },
    Cut: function() {
        return document.getElementById(‘data‘).value;
    },
    afterCut: function() {

    }
});

 

粘贴

var paste = new clipBoard(document.getElementById(‘data‘), {
    beforePaste: function() {

    },
    paste: function() {
        return document.getElementById(‘data‘).value;
    },
    afterPaste: function() {

    }
});

 

js实现剪切、复制、粘贴——clipBoard.js

标签:

原文地址:http://www.cnblogs.com/xiyangbaixue/p/5452308.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!