Last active
January 28, 2022 18:14
-
-
Save obrenoco/deb7fc408d47f4ea7c058a5720b6d6bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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