php - javascript how to make copy this text button -


i want make action of copy url javascript , used script doesn't work !
//at head

 <script language="javascript">   function clipboard()  {  holdtext.innertext = copytext.innertext;  copied = holdtext.createtextrange();  copied.execcommand("copy");     }      </script> 

at body

 <span id="copytext" style="height:150;width:162;background-color:pink">  <?php  echo $files[$i]." ";?>  </span>   <textarea id="holdtext" style="display:none;">  <?php  echo "test";?>  </textarea>  <button onclick="clipboard();">copy url</button> 

try this:

var n1 = document.getelementbyid('copytext'); var n2 = document.getelementbyid('holdtext');   n2.value = n1.value; 

or

var holdtext =  document.getelementbyid('copytext').innerhtml;   copied = holdtext.createtextrange();   copied.execcommand("copy"); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -