Javascript clipboardData Object provides the functionality to use windows clipboard to copy text using javascript function. You can use the member methods of clipboardData object supported by Javascript to copy text from the HTML document elements. clipboardData object supports 3 methods:
-
setData
-
getData
-
clearData
setData method of javascript clipboardData object accepts two parameter values as argument. First takes the value as format of data and second parameter value as source of data or text that is to be copied. First parameter for format type can have two types of values one as Text and other as Url. setData method returns Boolean type value based on the successful execution to copy text on clipboard.
getData method of javascript clipboardData object accepts one parameter as format type of data stored on clipboard i.e. Text or Url.
clearData method of javascript clipboardData object clears the data stored on the clipboard. clearData method doesn’t take any parameter value to execute.
<script type="text/javascript" language="javascript">
function copyText()
{
var copyDivText = document. getElementById( 'div1' ) .innerText;
var returnVal = window. clipboardData. setData( 'Text', copyDivText );
alert(returnVal);
document. getElementById( 'div2' ). innerText = window. clipboardData. getData( 'Text' );
}
</script>
<div id="div1">
Copy this text to the clipboard using javascript
</div>
<br />
<input type="button" id="btn" value="copy" onclick="copyText()">
<br />
<div id="div2">
</div>
Javascript copy text to clipboard uses the clipboardData objects that consume the system clipboard utility to store the data until new data is being copied on the system clipboard. You can paste the stored data on clipboard multiple times.
分享到:
相关推荐
import copy from 'copy-to-clipboard' ; copy ( 'Text' ) ; // Copy with options copy ( 'Text' , { debug : true , message : 'Press #{key} to copy' , } ) ; 原料药 copy(text: string, options: object): ...
copy-text-to-clipboard 在现代浏览器中将文本复制到剪贴板(0.2 kB)
import copy from 'copy-text-to-clipboard' ; button . addEventListener ( 'click' , ( ) => { copy ( ':unicorn::rainbow:' ) ; } ) ; 原料药 复制(文本,选项?) 将text复制到剪贴板。 返回是否成功复制...
剪贴板副本 轻量级复制到Web的剪贴板 该软件包的目的是在现代Web浏览器中使用最少的字节数提供简单的“复制到剪贴板”功能。 为此,此程序包仅支持现代浏览器。... copy ( 'This is some cool text' ) } ) 原
clipboard' , // with options [ 'nuxt-clipboard' , { autoSetContainer : true } ] ] , clipboard : { autoSetContainer : true }} :fire: 用法您可以通过使用$的copytext在几乎任何情况下app.$copyText或this.
代码如下:<!...<head>...meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /><meta name=”Keywords” content=”YES!B/S!” /><meta name=”Description”
Nuxt 剪贴板 Nuxt.js 的“复制到剪贴板”模块,使用 :recycling_symbol: 设置 使用 yarn 或 npm 将nuxt-clipboard依赖项添加到您的项目中 ...您可以通过使用$的copytext在几乎任何情况下app.$copyTex
= \supplyhog\ ClipboardJs \ ClipboardJsWidget :: widget ([ 'text' => "Hello World" , // 'label' => 'Copy to clipboard', // 'htmlOptions' => ['class' => 'btn'], // 'tag' => 'button',]) ?>//Button to...
clipboard-polyfill 使在网络上复制变得容易: clipboard.writeText("hello world");该库是现代基于Promise的的polyfill。 注意:自2020年6月下旬起,您可以在所有主要浏览器的稳定版本中使用navigator.clipboard....
在做项目时有一个需求,是需要复制内容到剪切板,因为有众多浏览器,所以要兼容性很重要。..."The text is on the clipboard, try to paste it!"); } [removed] 2、跨浏览器的,但是Firefox无法复制
# => outputs 'my_new_function_name' and copy it to your clipboard # Transforming text passed on stdin cat somefile | uppercase > somefile_uppercased 概括 随机情况 脚本级别 上标 下标 编码方式 ...
The benefit of a column maker is that it can help you to format your text/code, or in some cases to make it easier to read in complex nested logic. Quick Open UltraEdit and UEStudio provide multiple ...
a library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie adn a JavaScript interface 安装 $ spm install nd-zeroclipboard --save 使用 var Zeroclipboard = require...
simple-copy.js 将DOM,textarea或字段值复制到剪贴板,不使用Flash,最小化大小为2.3kB(压缩后为1.14kB)。 设置 包含库 < script src =" simple-copy.min.js " > </ script > 或使用CDN: < ...
灰烬剪贴板 这是.js的Ember.js附加组件。安装$ ember install ember-clipboard现场演示在此处观看实时演示: : 例<...{{ #clip-board class = " btn " target = " #foo " }} Click to copy{{ /clip-board }
<!...<... <... <div id="btn" data-clipboard-text="1"> <span>Copy <div id="btn" data-clipboard-text="2"> <span>Copy <!-- 2. Include library --> <script src="../dist
data-copy-text <button data-copy-text="Hello! how are you?">Click , Copy!</button>data-copy-from Enter Text : <input class="input_text" name="text" type="text"> <button data-...
XML越来越热,关于XML的基础教程网络上也随处可见。可是一大堆的概念和术语往往让人望而生畏,很多朋友问我:XML到底有什么用,我们是否需要学习它?我想就我个人学习过程的心得和经验,写一篇比较全面的介绍文章。...
uni-cli-converter 一个CLI工具,可以在不同的Unicode样式之间自动转换文本。 使用 正在安装: ... Copy to clipboard ? (Y/n) 例子 常规的 上标 小帽子 块脚本 你好,世界 ʷᵒʳˡᵈ ᴡᴏʀʟᴅ
情绪 在命令行上的文本中找到相关的表情符号 使用有关精彩文章中的API以及本地表情符号数据库。 安装 确保已安装版本10或更高版本。... --copy -c Copy the first emoji to the clipboard --skin-ton