I want to be able to initiate real paste event when user clicks. I can understand this may be a security issue, because if any webpage had access to users clipboard, that wo
It works differently with different browsers. You can find a working implementation here: https://jsfiddle.net/1vmansr2/
Relevant JS:
function myFunction() {
navigator.clipboard.readText()
.then(text => {
document.getElementById("demo").innerHTML = text;
})
.catch(err => {
document.getElementById("demo").innerHTML = 'Failed to read clipboard contents: '+err;
});
}