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

118
Views
No puedo copiar texto al portapapeles

Estoy usando hadlerbars como motor de vista para express y quiero que el texto en el código variable se copie en el portapapeles. Probé muchas soluciones. Este es mi código actual

 function copyLink() { var copytext = document.getElementById('alcslink').innerHTML let code = copytext.split(":- ").pop() /*formatted */ code.select(); code.setSelectionRange(0, 99999); /* For mobile devices */ /* Copy the text inside the text field */ navigator.clipboard.writeText(code.value); }

cuando ejecuto esto me da este error en la consola web

 TypeError: code.select is not a function
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Así es como lo uso:

Tenga en cuenta que no funciona en el motor de fragmentos. Deberá agregarlo a su código. Lo siento.

 const writeToClipboard = async (txt) => { const result = await navigator.permissions.query({ name: "clipboard-write" }); if (result.state == "granted" || result.state == "prompt") { await navigator.clipboard.writeText(txt); console.log('Copied to clipboard'); } }; document.querySelector('button').addEventListener('click', async () => { const el = document.querySelector('div'); await writeToClipboard(el.innerHTML); });
 <div>copy me</div> <button>Click</button>

about 4 years ago · Santiago Trujillo 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!