screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> </head> <body> <div id="app" class="container"> <h3>JavaScript Paste from Clipboard</h3> <textarea id="textarea" class="textarea"></textarea> <button id="paste-btn" class="paste-btn"> Paste from Clipboard </button> </div> <script> document.addEventListener("DOMContentLoaded", function () { const textarea = document.getElementById("textarea"); const pasteBtn = document.getElementById("paste-btn"); pasteBtn.addEventListener("click", () => { if (navigator.clipboard) { navigator.clipboard .readText() .then((text) => { textarea.value = text; }) .catch((error) => { console.error("Failed to read clipboard contents: ", error); }); } else { console.error("Clipboard API not supported in this browser."); } }); }); </script> <style> .container { background-color: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); border-radius: 8px; padding: 20px; width: 500px; margin: 0 auto; } h3 { margin-top: 0; margin-bottom: 20px; text-align: center; color: #333; } .textarea { width: 100%; height: 150px; padding: 10px; border: 1px solid #ccc; border-radius: 4px; resize: none; } .paste-btn { display: block; width: 100%; padding: 10px; margin-top: 10px; border: none; border-radius: 4px; background-color: #007bff; color: #fff; font-size: 16px; cursor: pointer; transition: background-color 0.3s ease; } .paste-btn:hover { background-color: #0056b3; } </style> </body> </html>