RedditPP Mascot

RedditPP

r/webdev • … • u/Chung_L_Lee

JS code that is working for years, suddenly no longer working.

If you try to capture the clipboard on Microsoft Edge version155.0.4283.62 (Official build) (64-bit), then it will say in dev console: " FAILED false NotAllowedError: Failed to execute 'readText' on 'Clipboard': Document is not focused."

However, the same code works fine with Chrome and Firefox. Is this a Microsoft Edge regression bug? I use this code everyday. So I am sure that it is a recent update that cause this. I have also tested that it has nothing to do with the origin.

// sample code document.addEventListener("click", async () => { try { const text = await navigator.clipboard.readText(); console.log("SUCCESS", text); } catch (e) { console.error("FAILED", document.hasFocus(), e); } });

— 0