<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<input type="text" id="input" name="input" />
<button id="btn">copy</button>
<script>
const input = document.getElementById("input");
document.getElementById("btn").addEventListener("click", function (e) {
if (navigator.clipboard) {
navigator.clipboard.writeText(input.value);
} else {
var textarea = document.createElement("textarea");
document.body.appendChild(textarea);
textarea.style.position = "fixed";
textarea.style.clip = "rect(0 0 0 0)";
textarea.style.top = "10px";
textarea.value = text;
textarea.select();
document.execCommand("copy", true);
document.body.removeChild(textarea);
}
});
</script>
</body>
</html>