Error: TypeError: navigator.share is not a function
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
What specific section or headline is this issue about?
Navigator.share()
What information was incorrect, unhelpful, or incomplete?
const shareData = { title: 'MDN', text: 'Learn web development on MDN!', url: 'https://developer.mozilla.org' }
const btn = document.querySelector('button'); const resultPara = document.querySelector('.result');
// Share must be triggered by "user activation"
btn.addEventListener('click', async () => {
try {
await navigator.share(shareData);
resultPara.textContent = 'MDN shared successfully';
} catch (err) {
resultPara.textContent = Error: ${err};
}
});
What did you expect to see?
Share API to work, currently returning error (Error: TypeError: navigator.share is not a function)
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
MDN metadata
Page report details
- Folder:
en-us/web/api/navigator/share - MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/navigator/share/index.md
- Last commit: https://github.com/mdn/content/commit/a243190b798aa57b6cc08b9ef3216aed8ab9c895
- Document last modified: 2022-09-22T16:39:52.000Z
This doesn’t seem like a report about a specific problem in MDN content but instead seems better suited to getting help with on a site such as Stack Overflow.