复制文字到剪切板的方法

IE
window.clipboardData.setData('Text',createClipboardData(param));
google,chrome
// 复制到剪切板
    function copyToClipboard(text) {
        var textArea = document.createElement("textarea");
        textArea.value = text;
        document.body.appendChild(textArea);
        textArea.select();
        try {
            var successful = document.execCommand('copy');
         } catch (err) {
        }
        document.body.removeChild(textArea);
    }

发布了36 篇原创文章 · 获赞 5 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/eyugod/article/details/76442238