我正在使用以下脚本:它在 Visual Studio 本地工作。但在服务器中它抛出
"Cannot read property 'write text' of undefined"
function GetCopyText(thislink) {
var Content = thislink.parentNode.parentNode.parentNode.parentElement.parentElement.parentElement.parentElement.children[2].children[0].children[0].innerText;
navigator.clipboard.writeText(Content).then(function () {
// alert('Async: Copying to clipboard was successful!');
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
}
最佳答案
使协议(protocol) https 并且浏览器应该运行它。
关于javascript - 复制剪贴板功能在本地工作但在服务器上不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52054635/