Skip to content

Commit

Permalink
Create index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
MohanRamSridhar authored Sep 25, 2024
1 parent cd5f20d commit 4d9e72e
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Copy Text Example</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
.container {
text-align: center;
}
textarea {
width: 300px;
height: 50px;
padding: 10px;
}
button {
margin-top: 10px;
padding: 10px 20px;
cursor: pointer;
}
</style>
</head>
<body>

<div class="container">
<textarea id="textBox">I how are you in there</textarea>
<br>
<button onclick="copyText()">Copy Text</button>
</div>

<script>
function copyText() {
var textBox = document.getElementById("textBox");
textBox.select();
textBox.setSelectionRange(0, 99999); // For mobile devices
navigator.clipboard.writeText(textBox.value).then(() => {
alert("Text copied to clipboard!");
}).catch(err => {
alert('Error copying text: ', err);
});
}
</script>

</body>
</html>

0 comments on commit 4d9e72e

Please sign in to comment.