可以在嵌入式网站中使用一个按钮。为什么?
我已经将网站纳入了另一个网站使用iframe。 < iframe src = ..“> ..
在嵌入式网站内部有一个复制按钮。当我在网站(无嵌入)中使用它时,它可以正常工作。但是当我在iframe中使用它时,它不会..
我的按钮代码: < button onClick =“ copy()”> copy</button>
JS:
function copy() {
let copyText = document.getElementById("resu");
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
navigator.clipboard.writeText(copyText.value.replace(/A /, "A ")).then(function() {
alert("Copied to clipboard.");
}, function(err) {
alert("Could not copy text.");
});
}
怎么了?
edit :通过使用< iframe src =“ ..”允许=“剪贴板 - 读取; clipboard-write;”>
..感谢
I have embedded an website inside another website using iframe..<iframe src=..">..
Inside the embedded website there is a copy button. When I use it in website(without embed) it works. But when I use it in iframe it doesn't..
My button code:<button onclick="copy()">copy</button>
Js:
function copy() {
let copyText = document.getElementById("resu");
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
navigator.clipboard.writeText(copyText.value.replace(/A /, "A ")).then(function() {
alert("Copied to clipboard.");
}, function(err) {
alert("Could not copy text.");
});
}
What's wrong??
Edit: This problem was solved by using <iframe src=".." allow="clipboard-read; clipboard-write;">
.. Thanks❤️
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论