Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

navigator.clipboard.readText() is not working in js

I have this code for paste:

navigator.clipboard.readText().then(
  clipText => document.querySelector("#Note").innerText += clipText);

But It has this error:

Uncaught TypeError: navigator.clipboard.readText is not a function

help me to solve this bug

like image 319
Nima Keshavarzian Avatar asked Dec 17 '22 11:12

Nima Keshavarzian


1 Answers

I'm guessing you are testing it in Firefox, in that case:

Firefox only supports reading the clipboard in browser extensions, using the "clipboardRead" extension permission.

https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText#browser_compatibility

like image 189
vanowm Avatar answered Dec 29 '22 19:12

vanowm