问题:javascript实现复制到剪切板,用ff浏览器显示TypeError: window.clipboardData is undefined
<script language="JavaScript"> function copyToBoard(id) { var text=document.getElementById(id).value; if (window.clipboardData.setData("text",text)) {alert("复制成功!")} else {alert("复制失败!")} } </script> <input id="copyId" type="text" /> <input type="button" value="复制a" onclick="copyToBoard(‘copyId‘);" />
原来clipboardData只能ie存在,在谷歌和火狐下clipboardData为null