-1
在我的代码,我试图使用复制到剪贴板按钮复制iframe的代码,但我并不满足,因为当我复制使用按钮,它拷贝<
和>
代替<
和>
其次它赢得“T突出了文本区域,从而没有任何替代的解决方案,以作为复制的HTML代码感谢 这是我的JSfiddlejQuery文档复制到剪贴板
下面是一个示例复制的文本
<iframe src='http://localhost/secvideo/cms/watch?v=30Rt9r' frameborder='0' style='overflow: hidden; position: absolute;' height='100%' width='100%'></iframe>
和这是我的JS
function copyToClipboard(elementId) {
var aux = document.createElement("input");
// Assign it the value of the specified element
aux.setAttribute("value", document.getElementById(elementId).innerHTML);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
alert("Copied!");
}
你的JS小提琴是不是做如你所描述的 - 犯规复制的。 – jdmdevdotnet
当您更改功能copyToClipboard(elementId)到window.copyToClipboard =功能(elementId)如期工作 – ajc2000
https://jsfiddle.net/yhpe990k/ < - 因为在这个小提琴做 – ajc2000