Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

76
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda