Abrir tela de compartilhamento nativo com JavaScript

53d atrás

0 0

O método navigator.share() do #JavaScript mostra o painel nativo de compartilhamento, com os apps disponíveis para compartilhar.

Sintaxe

navigator.share(data);
Data é um objeto com os seguintes atributos:
  • url: string - texto que representa a url a ser compartilhada
  • text: string - texto a ser compartilhado
  • title: string - texto do título
  • files: File[] - um array de arquivos a ser compartilhado

Exemplo

O exemplo abaixo abre a tela para compartilhar uma url:

navigator.share({
    url: 'https://insights.ionited.io' 
});

Referências

Para mais informações desse método, acesse:

Navigator: share() method - Web APIs | MDN

The share() method of the Navigator interface invokes the native sharing mechanism of the device to share data such as text, URLs, or files. The available share targets depend on the device, but might include the clipboard, contacts and email applications, websites, Bluetooth, etc.


Comentários (0)

0/512
Link