Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Javascript function skips navigator.clipboard.writeText and just does window.open

I have the following function:

function openurl(){
navigator.clipboard.writeText("TextToCopy");
window.open('url');
}

executing in this:

<button onclick=openurl()>Openurlbutton</button>

It only opens the window and does not copy the text. I am so lost.. help :D

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

navigator.clipboard.writeText is an async function. For you to work you can edit your code to the following. (https://www.w3.org/TR/clipboard-apis/#async-clipboard-api)

 async function openurl() {
      await navigator.clipboard.writeText('TextToCopy');
      window.open('url');
    }
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!