Browser Copy

Reference (plagiarism): https: //www.cnblogs.com/gyfluck/p/10254846.html

 

< Table > 
    < TR > < TD > Name: < span the onclick = "copyContent (the this);" title = "Click Copy" > John Doe </ span > </ TD > </ TR > 
    < TR > < TD > Name : < span the onclick = "copyContent (the this);" title = "click copy" > John Doe </ span > </ TD > </ TR > 
</ Table >

<input id="copy_content" type="text" value=""  style="position: absolute;top: 0;left: 0;opacity: 0;z-index: -10;"/>

< Script type = "text / JavaScript" > 
     function copyContent (ElementObj) {
          // get the value of the click 
         var clickContent = ElementObj.innerText;         
          // get the elements assigned to the input 
         var inputElement =   document.getElementById ( " copy_content " );
          // to input box assignment 
         inputElement.value = clickContent;
          // select the input box contents 
         inputElement.select ();
           // execute browser copy command 
         document.execCommand ( "Copy " );
          // prompt replicated 
         the ALTER ( ' Copied ' );

          
     }
</script>

 

Guess you like

Origin www.cnblogs.com/liouzeshuen/p/11898264.html