navigator.clipboard 浏览器原生剪贴板
浏览器原生剪贴板 navigator.clipboard
写入 navigator.clipboard.writeText
navigator.clipboard.writeText('Linr Text to be copied')
.then(() => {
console.log('Text copied to clipboard');
})
.catch(err => {
// This can happen if the user denies clipboard permissions:
console.error('Could not copy text: ', err);
});
读取 navigator.clipboard.readText
navigator.clipboard.readText()
.then(text => {
console.log('Pasted content: ', text);
})
.catch(err => {
console.error('Failed to read clipboard contents: ', err);
});
document.addEventListener('paste', event => {
event.preventDefault();
navigator.clipboard.getText().then(text => {
console.log('Pasted text: ', text);
});
});
原文:https://developers.google.com/web/updates/2018/03/clipboardapi
navigator.clipboard 浏览器原生剪贴板的更多相关文章
- Javascript复制内容到剪贴板,解决navigator.clipboard Cannot read property 'writeText' of undefined
起因 最近帮同事实现了一个小功能--复制文本到剪贴板,主要参考了前端大神阮一峰的博客,根据 navigator.clipboard 返回的 Clipboard 对象的方法 writeText() 写文 ...
- 原来浏览器原生支持JS Base64编码解码 outside of the Latin1 range
原来浏览器原生支持JS Base64编码解码 « 张鑫旭-鑫空间-鑫生活 https://www.zhangxinxu.com/wordpress/2018/08/js-base64-atob-bto ...
- 通过浏览器navigator判断浏览器版本或者手机类型&&判断微信访问
javascript 的navigator属性,不常用,但是用处也不少,主要用处是在做浏览器兼容的问题的时候,现在有的网站已经不兼容IE6,用户假如用IE6浏览网页的话,会提示浏览器升级等信息.或者判 ...
- navigator.userAgent浏览器检测(前端基础系列)
对于前端来说,浏览器检测已经不陌生了,在做一些页面是,需要针对不同的浏览器进行处理不同的逻辑,最简单的就是区分pc和移动端的浏览器,或是android 和ios下的浏览器. 一.浏览器检测的由来? ...
- JavaScript Window Navigator 浏览器本身的信息
window.navigator 对象包含有关访问者浏览器的信息. Window Navigator window.navigator 对象在编写时可不使用 window 这个前缀. Navigato ...
- navigator(浏览器对象)Screen对象(屏幕)
浅谈navigator对象: 注意:不是所有浏览器都支持 .cookieEnabled 判断是否启用了cookie 在客户端硬盘持久保存用户私密数据的小文件 .plugins 浏览器安装的所有插件 ...
- 现代浏览器原生js获取id号方法
<div id="tests" class="a b c" style="color:#f00">123</div> ...
- 纯css解决div隐藏浏览器原生滚动条,但保留鼠标滚动效果的问题
当我们的内容超出了我们的div,往往会出现滚动条,影响美观.尤其是当我们在做一些导航菜单的时候.滚动条一出现就破坏了UI效果. 我们不希望出现滚动条,也不希望超出去的内容被放逐,就要保留鼠标滚动的效 ...
- 浏览器原生 form 表单POST 数据的两种方式
我们在提交表单的时候,form表单参数中会有一个enctype的参数.enctype指定了HTTP请求的Content-Type. 常用有两种:application/x-www-form-urlen ...
随机推荐
- table-layout:fixed属性
说实话,第一次见到这个属性有点懵圈,真是没见过这个属性 好了,直接说作用 table-layout其实是一种表格算法,用来显示表格单元格.行.列的算法规则. 固定表格布局: 固定表格布局与自动表格布局 ...
- RePlace函数
<html><body> <script type="text/javascript"> var str="Visit qq1!&qu ...
- Dobble的学习视频地址
http://www.tebaidu.com/file-f698fb45eb1b5c59571936118968d86c89194311.html
- 工作流Activiti学习地址
http://blog.csdn.net/xnf1991/article/details/52610277
- 【Django】创建后的基本操作
1.创建Django项目做基本的配置步骤Pycharm->new->New Project 2.基本的配置settings.py-->STATIC_URL = '/static/'后 ...
- Kendo UI diagram 更改connnect线颜色,及shapes的属性值
1.改diagram中连线的颜色:redraw一下就OK // Change the Line Green diagram.connections[indexS].redraw({ stroke:{ ...
- luogu 自适应Simpson1
自适应simpson1 题意 求一个定积分 (可以手推公式,但是我不想推怎么办) 解法 用一个又一个的二次函数覆盖原函数,则可以近似的得到原函数的积分.(这就是Simpson) 模板在下面: #inc ...
- linux下如何查看cpu信息
linux的cpu信息可以从文件中cpuinfo读取. 执行命令: # cat /proc/cpuinfo 我们一般看到的processor是逻辑核. 它的计数是从0开始的,例如这里看到的是31 ...
- Python中的itertools.product
例子1:import itertoolsa = itertools.product([1,2,3],[100,200])print(a)for item in itertools.product([1 ...
- debian 9 安装无线网卡
#添加源 echo "deb http://httpredir.debian.org/debian/ stretch main contrib non-free" >> ...