js & auto copy
js & auto copy
https://developer.mozilla.org/zh-CN/docs/Web/Events/copy
Ctrl + C
Command + C
document.execCommand("copy");
https://developer.mozilla.org/zh-CN/docs/Web/API/Document/execCommand
https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript
document.execCommand("copy");
Chrome copy
JSON.stringify(JSON.parse(window.sessionStorage.getItem("flipObj")), null, 4);
let obj = {
"dataType": "0",
"publishTime": "2019-01-23 10:18:46",
"newsId": "05201901230103749163041",
"dataStatus": "",
"handleUser": "",
"xwbt": "",
"mtcc": "",
"gkbz": ""
};
copy(obj);
chromeCopy() {
try {
if (window.copy) {
window.copy(obj);
}
} catch (error) {
//
}
},
click copy & demo
clickGetNewsLink(data_ref = `newsLink`) {
let that = this;
let newsLink = document.querySelector(`[data-uid="${data_ref}"]`);
// let newsLink = document.querySelector(`[data-uid="newsLink"]`);
if (newsLink) {
let result = that.commonHandle.newsLink || ``;
let input = newsLink.lastElementChild;
input.addEventListener(`click`, (e) => {
try {
if (result) {
input.select();
document.execCommand("copy");
that.$hMessage.success(`资讯链接地址, 复制成功!`);
} else {
that.$hMessage.info(`资讯链接地址, 无法复制!`);
}
} catch (err) {
console.log(`click copy error =`, err);
that.$hMessage.error(`你的浏览器太古老了,暂时不支持点击复制的功能!`);
}
});
}
},
clickGetNewsId() {
let that = this;
let newsID = document.querySelector(`[data-uid="newsId"]`);
if (newsID) {
let result = that.commonHandle.newsId || ``;
let input = newsID.lastElementChild;
// input.style = `width: 100%; min-width: 217px; color: #000; cursor: pointer !important;`;
input.addEventListener(`click`, (e) => {
try {
if (result) {
input.select();
document.execCommand("copy");
that.$hMessage.success(`资讯 ID, 复制成功!`);
} else {
that.$hMessage.info(`资讯 ID 为空, 无法复制!`);
}
} catch (err) {
console.log(`click copy error =`, err);
that.$hMessage.error(`你的浏览器太古老了,暂时不支持点击复制的功能!`);
}
});
} else {
//
}
},
js & auto copy的更多相关文章
- js auto hover button & html5 button autofocus
js auto hover button & html5 button autofocus input // html 5 <input name="myinput" ...
- (网页)Angular.js 中 copy 赋值与 = 赋值 区别
转自st.gg Angular.js 中 copy 赋值与 = 赋值 区别 为什么用 $scope.user = $scope.master; $scope.master 会跟着 $scope.use ...
- js & click copy to clipboard
js & click copy to clipboard https://www.cnblogs.com/xgqfrms/p/9999061.html https://www.cnblogs. ...
- trao 模拟点击 & js auto click
trao 模拟点击 & js auto click 日历上选择某一天,在 scrollview 自动定位到选择的那一天 click 后获取 item 的 e.target.offsetLeft ...
- scrollTo & js auto scroll & scrollX & scrollY
scrollTo & js auto scroll & scrollX & scrollY scrollX & scrollY 获取 scroll top height ...
- js clear copy
js clear copy window.getSelection().empty() & window.getSelection().removeAllRanges() & docu ...
- js深浅copy
...点copy是浅拷贝var obj1 = [1,{a: 1}];//var obj2 = Object.assign( {}, obj1);//浅copy//var obj2 = JSON.par ...
- js Functor Copy
原文地址:https://segmentfault.com/a/1190000006051586?utm_source=tuicool&utm_medium=referral 本处仅仅个人存档 ...
- js 对象 copy 对象
function clone(myObj) { if (typeof (myObj) != 'object') return myObj; if (myObj == null) return myOb ...
随机推荐
- ModelForm解密
一.复用model表和字段 models.py文件 class User(models.Model): username = models.CharField(max_length=32) emai ...
- Intellij IDEA《十分钟,配置struts2》by me
1.加载Struts 2类库 <dependencies> <!-- Struts 2 核心包--> <dependency> <groupId>org ...
- mysql自动化测试第一个例子
################################################################################ # This test verifie ...
- nginx Location正则表达式
1. Location正则表达式 1.1. location的作用 location指令的作用是根据用户请求的URI来执行不同的应用,也就是根据用户请求的网站URL进行匹配,匹配成功即进行相关的操作. ...
- hdu2544最短路(dijkstra)
传送门 dijkstra #include<bits/stdc++.h> using namespace std; const int INF=0x3f3f3f3f; ; int dist ...
- WebGL之sprite精灵效果显式数字贴图
接着前一篇<WebGL实现sprite精灵效果的GUI控件>,我们继续开发我们的数字系统GUI控件,因为这套数字系统是基于sprite效果的,所以数字随相机转动而旋转(永远面对相机),随场 ...
- TPO-21 C2 Which elective courses to take
/* 加粗:语音部分 * 红色:单词部分 * 斜体:语法部分 * 下划线:信号词/句 */ 第 1 段 1.Listen to a conversation between a student and ...
- (2) English Learning
数词 数词有基数词和序数词两种.英语的数词可以作句子的主语.宾语.表语和定语. 基数词:表示数目的词叫基数词. 1. 英语中常用的基数词有:除了图片上的,还有以下一些 1000→one(a) th ...
- Gitlab CI-1.Gitlab部署
参考文档: GitLab Documentation:https://docs.gitlab.com/ce/ Installation and Configuration using omnibus ...
- 从零开始的Python学习Episode 19——面向对象(2)
面向对象之继承 继承是一种创建新类的方式,新建的类可以继承一个或多个父类(python支持多继承),父类又可称 为基类或超类,新建的类称为派生类或子类. 子类会“”遗传”父类的属性,从而解决代码重用问 ...