Skip to content

0x5457/do-copy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

do-copy

在现代浏览器中执行复制命令

Install

npm i do-copy -S
# or yarn add do-copy

Use

import doCopy from "do-copy";

// 检查浏览器是否支持复制命令
let isSupported = doCopy.isSupported();

button.onclick = () => {
  // 复制普通文本
  let ok = doCopy.copyText("copy this text!");
  console.log(ok);
};

button.onclick = () => {
  // 复制 html 格式文本
  let ok = doCopy.copyHtml("<div>123<img src="https://www.baidu.com/img/bd_logo1.png" /></div>");
  console.log(ok);
};

button.onclick = () => {
  // 复制html元素
  let ok = doCopy.copyFromElem("body");
  console.log(ok);
};

button.onclick = () => {
  // 复制html元素
  let ok = doCopy.copyFromElem(document.querySelector("div"));
  console.log(ok);
};

Features

API 简洁

License

MIT License © Tao Wei

About

在浏览器中执行复制

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published