Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
El botón Copiar HTML al portapapeles no funciona

Estoy tratando de hacer un botón para copiar un enlace ( www.google.com ) al portapapeles, pero no funciona. mi código es:

 <script type='text/javascript'> function myFunction() { /* Get the text field */ var copyText = document.getElementById("www.google.com"); /* Select the text field */ copyText.select(); copyText.setSelectionRange(0, 99999); /* For mobile devices */ /* Copy the text inside the text field */ navigator.clipboard.writeText(copyText.value); /* Alert the copied text */ alert("Copied link!"); } </script>

Y el botón:

 <button onclick='myFunction()'>Clik to copy the Link</button>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

intente esto con la función asíncrona y espere

 async function copyGoogleLink(){ await navigator.clipboard.writeText('https://www.google.com') .then(() => console.log('Copied')); }

use esto con Event Listener

about 4 years ago · Juan Pablo Isaza Denunciar

0

Esto te ayudara

 function copyToClipboard(text) { if (navigator.clipboard) { return navigator.clipboard.writeText(text); } const element = document.createElement('span'); element.textContent = text; element.style.whiteSpace = 'pre'; document.body.appendChild(element); const selection = window.getSelection(); const range = document.createRange(); selection.removeAllRanges(); range.selectNode(element); selection.addRange(range); document.execCommand('copy'); selection.removeAllRanges(); document.body.removeChild(element); }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda