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

215
Visualizações
Copy clipboard function working locally but not working server

I am using the below script: It is working locally in visual studio. but in server it throws

"Cannot read property 'write text' of undefined"

 function GetCopyText(thislink) {
    var Content = thislink.parentNode.parentNode.parentNode.parentElement.parentElement.parentElement.parentElement.children[2].children[0].children[0].innerText;

    navigator.clipboard.writeText(Content).then(function () {
        // alert('Async: Copying to clipboard was successful!');
    }, function (err) {
        console.error('Async: Could not copy text: ', err);
    });
}
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Make the protocol https and the browser should run it.

over 4 years ago · Santiago Trujillo Relatório

0

Maybe it's too late (and the code for a couple of sites looks like this). but the guy doesn't do that:

 var Content = thislink. parentNode.parentNode.parentNode. parentElement.parentElement.parentElement.parentElement. children[2].children[0].children[0]. innerText;
over 4 years ago · Santiago Trujillo Relatório

0

Clipboard feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

https://developer.mozilla.org/en-US/docs/Web/API/Clipboard

Thanks Wade

Suggestions: its better to check navigator.clipboard value and proceed only if exists. This provides good user experience and In large organizations, since many developers will be running UI in local mode for testing, It saves their debugging time and then figure out navigator.clipboard is not available in local mode without https.

over 4 years ago · Santiago Trujillo Relatório
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