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

189
Vistas
Unable to make custom copy event listener, bound to an element, work properly

I have added a custom event listener to copy/cut of text from an element (say elementId). Now when I copy from elementId and paste on word the functionality works fine. But when I copy from the elementId and paste on notepad, the paste doesn't work. By doesn't work I mean nothing is pasted at all.

document.getElementById(config.editorEl).addEventListener('copy', function(event) {
    const range = window.getSelection().getRangeAt(0);
    const content = range.cloneContents();
    const div = document.createElement('div');
    div.appendChild(content);
    $(div)
    .find('.remove_this_class')
    .contents()
    .unwrap();
    event.clipboardData.setData('text/html', div.innerHTML);
    event.preventDefault();
    });

Summary: The custom copy/cut handler doesn't work properly.

  • Copy - paste on word (works correctly)
  • Copy - paste on notepad(Nothing gets pasted at all)
  • Copy - paste on url bar (Nothing gets pasted at all)
about 4 years ago · Juan Pablo Isaza
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