Skip to content

Commit

Permalink
Merge pull request loverajoel#365 from hingsir/patch-9
Browse files Browse the repository at this point in the history
fix typo zh_CN
  • Loading branch information
sjfkai authored Aug 4, 2016
2 parents e054e9f + 7cac893 commit d42c694
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _posts/zh_CN/2016-08-02-copy-to-clipboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ categories:

这是一个简单的小知识,本周我做了一个简单的“复制到剪贴板”按钮,这是我第一次做这种功能,向大家分享一下我的实现方法。

这很简单,比较麻烦的是我们必须为需要复制的文本增加`<input/>`标签。之后我们选择要复制的任荣然后调用复制命令[execCommand](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/execCommand).
这很简单,比较麻烦的是我们必须为需要复制的文本增加`<input/>`标签。之后我们选择要复制的内容然后调用复制命令[execCommand](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/execCommand).
`execCommand('copy')` 将会复制被选择的内容。

此方法目前被所有最新版本的浏览器[支持](http://caniuse.com/#search=execCommand),它可以让我们执行如`复制``剪切``粘贴`等命令,还可以改变字体颜色、大小等。
Expand All @@ -23,4 +23,4 @@ document.querySelector('#input').select();
document.execCommand('copy');
```

具体表现看[这里](https://jsbin.com/huhozu/edit?html,js,output)
具体表现看[这里](https://jsbin.com/huhozu/edit?html,js,output)

0 comments on commit d42c694

Please sign in to comment.