Native workers can click Copy js

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>

  
  <a id="weixin" onClick="copyFn()" href="javascript:;">
    <font color="#FF00FF" id="copyMy"> Micro Signal: shaonv77882 </ font > 
  </ A > 
  
    < span the above mentioned id = "copyMy" > Copy I try </ span > 
    < the Button onClick = "copyFn ()" > Click Copy </ the Button > 


  < Script > 
    function copyFn () {
       var Val = document.getElementById ( ' copyMy ' ); 
      window.getSelection () selectAllChildren (Val);. 
      document.execCommand ( " the Copy ");
      alert(" You have micro-replicated signal! " ); 
    } 
  </ Script > 
  
  
  // note can not hide the label to be copied 

  @ Method two: 
  < Script type = "text / JavaScript" > 
    function copyUrl2 () {
       var Url2 = document.getElementById ( " biao1 " ); 
      Url2.select (); // select the object 
      document.execCommand ( " the copy " ); // browser is executed copy command 
      Alert ( " copied, and can be sticky paste. " ); 
    } 
  </ Script> 
  < TextArea cols = "20 is" rows = "10" ID = "biao1" > Code area of the user-defined </ TextArea > 
  < INPUT type = "Button" the onClick = "copyUrl2 ()" value = "Click Copy Code"  / > 
</ body > 
</ HTML >

 

Guess you like

Origin www.cnblogs.com/seanpan/p/11486862.html