1. 버튼을 클릭하여 텍스트 상자에 내용을 복사합니다.
<script type = "text/javaScript"> function copyurl2 () {var url2 = document.getElementById ( "biao1"); url2.select (); // 객체를 선택하십시오. // 브라우저 사본 ALERT ( "copy, you paste.");}} </script> <textRea cols = "20"rows = "10"id = "biao1"> user-defined code are </textArea> <입력 유형 = "button"onclick = "copurl2 ()"value code = "copy copy to copy covip"/>2. 주제 주소와 URL 주소를 복사하여 QQ/MSN에서 친구에게 전달하십시오.
<! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w.w.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><Html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type"content = "text/html; charset = gb2312"/> <title> js 사본 코드 </head> <p> <input type = "anniu1" onclick = 'coppytoclipboard ()'value = "주제 주소와 URL 주소를 복사하여 qq/msn"> <script language = "javaScript"> function copyToclipboard () {var ClipboardContent = ""; ClipboardContent+= document.title; clipboardContent+= ""; ClipboardContent+= this.location.href; wind3. URL을 직접 복사하십시오
<input type = "button"name = "anniu2"onclick = 'copyurl ()'value = "Copy URL 주소"> <script language = "javaScript"> function copyurl () {var clipboardContent = this.location.href; window.clipboard.setData ( "text", clipboardContent); "Copy!"4. 텍스트 상자를 클릭 할 때 텍스트 상자의 내용을 복사하십시오.
<input onclick = "ocopy (this)"value = "hello.
5. 텍스트 상자에 내용을 복사하거나 필드를 숨기십시오.
<script language = "javaScript"> 함수 copyurl (target) {target.value = myimg.value; target.select (); js = myimg.creatextrange (); js.ExecCommand ( "copy"); alert ( "copy success!");} 함수 addimg (target) {target.value = "[img]" "+myimg.value+"[/ img] "; target.select (); js = target.creatextrange (); js.Execcommand ( "copy"); Alert ( "Copy Encthuent!");} </script>6. 스팬 태그에 내용을 복사하십시오
<script type = "text/javaScript"> </script> <br/> <br/> <script type = "text/javaScript"> 함수 CopyText (obj) {var rng = document.body.creatextrange (); rng.movetoelementtext (obj); rng.scrollintoview (); rng.select (); rng.execcommand ( "copy"); rng.collapse (false); alert ( "copy sext!")} </script>7. CopyToclipboard와 호환되는 브라우저 ( "Copy Content")
함수 copytoclipboard (txt) {if (wind clipboarddata.setData ( "text", txt); 경고 ( "성공적으로 복사하십시오!"); } else if (navigator.useragent.indexof ( "opera")! = -1) {window.location = txt; } else if (wind } catch (e) {alert ( "브라우저에 의해 거부 됨! /n Enter 'invect : config'브라우저 주소 표시 줄에서 Enter /n을 누르고 'signed.applets.codebase_principal_support'를 'true'"로 설정합니다. } var clip = components.classes [ '@mozilla.org/widget/clipboard ;1'] .CreateInstance(components.interfaces.nsiclipboard); if (! clip) 반환; var trans = components.classes [ '@mozilla.org/widget/transferable ;1'] .createinstance(components.interfaces.nsitransferable); if (! clip) 반환; var trans = components.classes [ '@mozilla.org/widget/transferable ;1'] .createinstance(components.interfaces.nsitransferable); if (! trans) 반환; trans.adddataflavor ( "Text/Unicode"); var str = new Object (); var len = new Object (); var str = components.classes [ "@mozilla.org/supports-String ;1"ECREATEINSTANCE(components.interfaces.nsisupportsString); var copyText = txt; str.data = 카피 텍스트; trans.settransferdata ( "Text/Unicode", str, copyright.length * 2); var clipid = components.interfaces.nsiclipboard; if (! clip) false를 반환합니다. clip.setData (trans, null, clipid.kglobalclipboard); 경고 ( "성공적으로 복사하십시오!"); }}8. 주요 브라우저의 사본 코드와 호환됩니다 (Zeroclipboard.js와 결합)
<html> <head> <title> Zero Clipboard Test </title> <script type = "text/javaScript"src = "zeroclipboard.js"> </script> <script ancegry = "javaScript"> var clip = null; function $ (id) {return document.getElementById (id); } function init () {clip = new Zeroclipboard.client (); Clip.SethandCursor (True); clip.adeventListener ( 'mouseover', function (client) {// clip.settext ($ ( 'fe_text'). value);})를 통해 마우스에서 텍스트를 업데이트합니다. clip.adeventListener ( 'complete', function (client, text) {// debugstr ( "클립 보드에 복사 한 텍스트 :" + text); Alert ( "이 주소가 복사되어 ctrl + v로 붙여 넣을 수 있습니다");}); clip.glue ( 'clip_button', 'clip_container'); }.