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

72
Vistas
Copy Image as HTML hyperlink via clipboard not working in MacOS

Copy to clipboard works fine in Windows PC on Google Chrome Browser, but it doesn't work with MacOS in Google Chrome Browser inside Wyswig editor of Email Marketing tools like Snovio.

Here is my code:

 let htmlBlock =  `<a style="padding: 10px 0px; max-width: 360px;" href="https://commons.wikimedia.org/wiki/Category:Images#/media/File:Volkswagen_Beetle_7.jpg" alt="Car Image"> <img height="168" width="300" src="https://commons.wikimedia.org/wiki/Category:Images#/media/File:Volkswagen_Beetle_7.jpg" alt="Car Image" /></a>`
 
 copyToClipboard(htmlBlock);



  function copyToClipboard(element) {



    // Create container for the HTML
    // [1]
    let html = element
    var container = document.createElement('div')
    container.innerHTML = html
    // Hide element
    // [2]
    container.style.position = 'fixed'
    container.style.pointerEvents = 'none'
    container.style.opacity = 0
    // Detect all style sheets of the page
    var activeSheets = Array.prototype.slice.call(document.styleSheets)
      .filter(function (sheet) {
        return !sheet.disabled
      })
    // Mount the container to the DOM to make `contentWindow` available
    // [3]
    document.body.appendChild(container)
    // Copy to clipboard
    // [4]
    window.getSelection().removeAllRanges()
    var range = document.createRange()
    range.selectNode(container)
    window.getSelection().addRange(range)
    // [5.1]
    document.execCommand('copy')
    // [5.2]
    for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true
    // [5.3]
    document.execCommand('copy')
    // [5.4]
    for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = false
    // Remove the container
    // [6]
    document.body.removeChild(container)

  
  }

The same code works with Gmail editor in MacOS as well.

Any idea on what I could be missing or could it be very specific to Snovio platform?

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