Skip to content

Instantly share code, notes, and snippets.

@obrenoco
Last active January 28, 2022 18:14
Show Gist options
  • Save obrenoco/deb7fc408d47f4ea7c058a5720b6d6bc to your computer and use it in GitHub Desktop.
Save obrenoco/deb7fc408d47f4ea7c058a5720b6d6bc to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
</head>
<body></body>
<script>
if (navigator.clipboard) {
const para = document.createElement("p");
para.innerText = "Navigator clipboard works in this browser 👍";
document.body.appendChild(para);
}
if (navigator.clipboard.writeText) {
const para = document.createElement("p");
para.setAttribute("id", "clibboard");
document.body.appendChild(para);
document.getElementById("clibboard").innerText = "sayyy";
navigator.clipboard
.readText()
.then(
(value) => {
console.log("success", value);
},
(reason) => {
console.log("error", reason);
}
)
.then((clipText) =>
console.log((document.getElementById("clibboard").innerText = clipText))
);
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment