与页面复制粘贴有关的方法
// 获取裁剪版内容
const getClipboard = async function () {
const value = await navigator.clipboard.readText()
return value
}
// 获取页面选中的文字
const getSelectText = function () {
return window.getSelection().toString()
}
// 设置粘贴内容
const setClipboard = async function (value = ' ') {
const text = document.createElement('textarea');
text.value = value;
document.body.appendChild(text);
text.select();
document.execCommand('Copy');
text.remove();
}
本文标题:与页面复制粘贴有关的方法
本文链接:https://www.haomeiwen.com/subject/chggsrtx.html
网友评论