javascript - 将换行符添加到复制缓冲区
问题描述
我不知道如何将换行符添加到复制缓冲区,然后可以将其粘贴到带有断行的谷歌表格中。我需要一个 HTML (br / p) 行为。当我们选择带有此类换行符的文本并在表单中逐行传递时。
我不想为此创建一个新窗口:
let string="";
document.querySelectorAll('p').forEach(el => {string+= el.innerText + "<br/>"});
let newWin = window.open("", "Title");
newWin.document.body.innerHTML=string;
newWin.getSelection().selectAllChildren(newWin.document.body);
newWin.execCommand("copy");
}
解决方案
推荐阅读
- websocket - 具有最大连接数的 ActiveMQ Websocket 传输
- c# - 如何动态绑定具有“React”状态的数据模型?
- mysql - 通过mysql或rails在数据库之间传输记录更好吗?
- javascript - 无法使用 Jquery 或 Javascript 更新输入框的值
- javascript - 点击超链接需要在html中显示一个编辑表单
- nodes - amChart 4 强制定向树动态字体大小
- windows - 如何使用 Perl 将文件从 Unix 目录复制到 Windows 目录?
- excel - 使用 VBA 对图形进行排序
- gradle - Intellij idea 为 ReplaceTokens 引发错误
- python - Python:行在输出上执行两次