This is a JS copy button that imitates Youku's video sharing and is compatible with various browsers.
<! -- Copy button JS --> <SCRIPT> function copytoclipboard (txt) {If (window. clipboardData) {window. clipboardData. cleardata (); window. clipboardData. setdata ("text", document. getelementbyid (txt ). value);} else if (navigator. useragent. indexof ("Opera ")! =-1) {// do nothing} else if (window. netscape) {try {Netscape. security. privilegemanager. enableprivilege ("universalxpconnect");} catch (e) {alert ("rejected by the browser! \ N enter 'about: config' in the address bar of the browser, press enter \ n, and then 'signed. applets. codebase_principal_support 'is set to 'true' ");} var clip = components. classes ['@ mozilla.org/widget/clipboard1_1').createinstance (components. interfaces. nsiclipboard); If (! Clip) return; var trans = components. classes ['@ mozilla.org/widget/transferable1_1'assist.createinstance (components. Interfaces. nsitransferable); If (! Trans) return; trans. adddataflavor ('text/Unicode '); var STR = new object (); var Len = new object (); var STR = components. classes ["@ mozilla.org/supports-string1_1"]. createinstance (components. interfaces. nsisupportsstring); var copytext = txt; Str. data = copytext; trans. settransferdata ("text/Unicode", STR, copytext. length * 2); var clipid = components. interfaces. nsiclipboard; If (! Clip) return false; clip. setdata (trans, null, clipid. kglobalclipboard);} alert ("You have successfully copied this address. Please paste it and recommend it to your friends! ") ;}</SCRIPT>
**************************************** **************************************** *************
Usage:
<! -- Share dialog box --> <Div class = "share"> <Div class = "sharetop"> </div> <Div class = "sharebord"> <H4> share with the website friend </H4> <Div class = "item"> <SPAN class = "label"> video address: </span> <input type = "text" id = "link1" value = "http://www.moredoo.com/10002"/> <button onclick = "javascript: copytoclipboard ('link1 '); "> copy </button> </div> <H4> paste the video to a blog or BBS </H4> <Div class =" item "> <SPAN class =" label "> flash Address: </span> <input type = "text" id = "link2" value = "http://www.moredoo.com/10002"/> <button onclick = "javascript: copytoclipboard ('link2 '); "> copy </button> </div> <Div class =" item "> <SPAN class =" label "> HTML code: </span> <input id = "link3" type = "text" value = '<embed src = "http://www.moredoo.com/10002" allowfullscreen = "true" Quality = "high" width = "480 "Height =" 400 "align =" Middle "allowScriptAccess =" always "type =" application/X-Shockwave-flash "> </embed> '/> <button onclick =" javascript: copytoclipboard ('link3'); "> copy </button> </div> <Div class =" sharebutom ">
The effect is as follows:
Effect: