Advertisement
Ajwct

Automatic Copy and Paste Script

Nov 9th, 2023
1,094
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. // Get the text you want to copy
  2. var textToCopy = "Hello, World!";
  3.  
  4. // Create a textarea element dynamically
  5. var textarea = document.createElement('textarea');
  6.  
  7. // Set the value of the textarea to the text you want to copy
  8. <textarea.value = textToCopy;
  9.  
  10. // Append the textarea to the document
  11. document.body.appendChild(textarea);
  12.  
  13. // Select the text inside the textarea
  14. <textarea.select();
  15.  
  16. // Copy the selected text to the clipboard
  17. document.execCommand('copy');
  18.  
  19. // Remove the textarea from the document
  20. document.body.removeChild(textarea);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement