เช่นรหัส JS:
การคัดลอกรหัสมีดังนี้:
<script type = "text/javascript">
ฟังก์ชั่น copyurl2 ()
-
var url2 = document.getElementById ("BIAO1");
url2.select ();
document.execcommand ("คัดลอก");
การแจ้งเตือน ("สำเนาสามารถวางได้");
-
</script>
<textarea cols = "20" rows = "10" id = "BIAO1"> พื้นที่รหัสที่ผู้ใช้กำหนด </textarea>
<อินพุต type = "ปุ่ม" onclick = "copyurl2 ()" value = "คลิกเพื่อคัดลอกรหัส" />
รหัส Chrome JS:
การคัดลอกรหัสมีดังนี้:
<script src = "http://www.weicaiyun.com/assets/js/copy/zeroclipboard.js"> </script>
<script type = "text/javascript">
var clip = new Zeroclipboard.client ();
Clip.SethandCursor (จริง);
clip.settext ('คัดลอกเนื้อหา');
clip.glue ('ปุ่ม');
</script>
<input type = "ปุ่ม" id = "button" value = "คลิกเพื่อคัดลอกรหัส" />