How-to paste text from clipboard automatically onload page

<textarea id="pasteArea" cols="50" rows="10"></textarea><br>

<script>

window.addEventListener('load', (event) => {
let pasteArea = document.getElementById('pasteArea');
pasteArea.focus();
pasteArea.value = '';

navigator.clipboard.readText()
.then((text)=>{
pasteArea.value = text;
});
})
</script>

In this example we'll learn how to paste text from clipboard automatically inside specific textarea on page is loaded, we need textarea tag and clipboard API JavaScript code to do this.
If you copied certain text, it will be pasted automatically in the text box.
in Chrome browser asks for permission How-to paste text from clipboard automatically onload page,  paste text,clipboard, javascript

© 2025 Manajmnt code

Share to :

Related

Comments