js设置剪切板文本,兼容chrome
2021-03-12 16:29
标签:and exe 兼容 plain cti doc chrome href def 本文摘自:https://zhuanlan.zhihu.com/p/38052227 js设置剪切板文本,兼容chrome 标签:and exe 兼容 plain cti doc chrome href def 原文地址:https://www.cnblogs.com/lroy/p/12826512.htmlfunction setClipBoardData(text) {
var copy = function (e) {
e.preventDefault();
if (e.clipboardData) {
e.clipboardData.setData(‘text/plain‘, text);
} else if (window.clipboardData) {
window.clipboardData.setData(‘Text‘, text);
}
}
window.addEventListener(‘copy‘, copy);
document.execCommand(‘copy‘);
window.removeEventListener(‘copy‘, copy);
}
文章标题:js设置剪切板文本,兼容chrome
文章链接:http://soscw.com/index.php/essay/63755.html