Domanda

i'm using a simple code to select all text inside textarea but i want the button to copy the text into the clipboard instead of using right click or Ctrl+c. here's the select code:

<form>
<textarea name='text_area' rows=1 cols=20 >large/<?php echo $row['Img_Name']; ?> 
</textarea> 
<input type='button' value='select path' onClick='javascript:this.form.text_area.focus(); this.form.text_area.select();'>
</form></div>

many websites add buttons to copy code or text just open this page and click share on the video and choose embed you'll get a copy button without the need to select the text or add the website to the white list http://techcrunch.com/2014/03/13/zuckerberg-called-obama-to-express-frustration-over-new-nsa-revelations/?source=gravity

È stato utile?

Soluzione

mozilla, like most other browsers doesn't let js manipulate the clipboard, unless the user set your website on a whitelist.

http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard

in response to your edited question: the video uses flash to copy to clipboard. There are several librarys that do so using hidden Flash content, for example ZeroClipboard

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top