-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd5f20d
commit 4d9e72e
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
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> |