开发者

javascript---click copy the content to the clipboard [duplicate]

开发者 https://www.devze.com 2023-02-01 17:21 出处:网络
This question already has answers开发者_运维问答 here: How do I copy to the clipboard in JavaScript?
This question already has answers开发者_运维问答 here: How do I copy to the clipboard in JavaScript? (75 answers) Closed 9 years ago.

the following is the code. but it doesn't work. what's wrong with it? thank you.

      <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>no title</title>
   <script type="text/javascript">
      function copyToClipBoard(content){
 var clipBoardContent = ''; 
clipBoardContent = content;
 window.clipboardData.setData("Text",clipBoardContent);
 alert('have copied to the clipboard');
}

 <body>
<textarea rows="4" cols="60" id="url">www.example.com</textarea>
     <input type="button" value="click me" onclick="copyToClibBoard (document.getElementById   ('url').value);" />

</body>


You cannot do this in Javascript.

Instead, you need to use Flash.

0

精彩评论

暂无评论...
验证码 换一张
取 消