本範例 HTML 語法: <div id="copy1" align="center" style="height: 30px;"> <img src="pics/copy.png" width="153" height="54"> HTML語法:<textarea id='mycode1' cols="67" rows="4" onClick="select_all('mycode1');"> <!--copy begin here--> <a target=_blank href=http://www.webpage.idv.tw/study/>網頁研習室 HTML 教學</a> <!--copy end here--> </textarea> </div>
本範例 JavaScript 語法: <script type="text/javascript" src="copy.js"></script> <script language="javascript"> var clip1 = new ZeroClipboard.Client(); clip1.setText( "" ); clip1.setHandCursor( true ); clip1.setText( document.getElementById("mycode1").value ); clip1.addEventListener("complete", function(client) { alert("複製成功,你現在可以貼到你的部落格或網站了!"); } ); if (clip1.div) { clip1.receiveEvent("mouseout", null); clip1.reposition("copy1"); }else clip1.glue("copy1"); function select_all(obj){ var text_val=document.getElementById(obj); text_val.focus(); text_val.select(); } </script>