問題:javascript實現複製到剪切板,用ff瀏覽器顯示TypeError: window.clipboardData is undefinedjavascript
<!-- lang: js --> <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爲nulljava