Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't my navigator.clipboard code work when pasting text from clipboard into input in Firefox? [closed]

I want to have a button to paste some text (from the clipboard) into an input field.

The following snippet works in Chromium, but not in Firefox.

<input>
<button>paste</button>
<script>
    document.querySelector('button').addEventListener('click', () =>
        navigator.clipboard.readText().then(text => document.querySelector('input').value = text)
    );
</script>

Is there a way to achieve the same effect in Firefox?

like image 363
Johannes Buchholz Avatar asked Jan 20 '26 17:01

Johannes Buchholz


1 Answers

Pasting on command now fully works as of Firefox 125. The demo code you provided will work.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!