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

253
Visualizações
Blazor server, copy to clipboard is failing in Safari

I added some simple functionality to copy a link to the clipboard, it works fine in Edge and Chrome but is failing in Safari with the following error:

The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

I believe this is because Safari wants you to do it via the click event and Blazor is routing the request through it's interop layer.

Has anyone got this to work?

Sample code:

Razor:

<button title="Copy link to clipboard" @onclick="@(e=> CopyToClipboard("someText"))">Copy</button>

C#:

        private async Task CopyToClipboard(string textToCopy)
        {
            await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", textToCopy);
        }

I had the javascript call in a separate javascript file, in a function, but was getting the same result.

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