This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The Navigator.share()
method invokes the native sharing mechanism of the device as part of the Web Share API. If the Web Share API is unsupported, then this method will be undefined
.
var sharePromise = window.navigator.share(data);
url
: A USVString
representing a URL to be shared.text
: A USVString
representing text to be shared.title
: A USVString
representing the title to be shared.A Promise
that will resolve once a user has completed a share action. It will reject immediately if the data parameter is not correctly specified.
For example, on Chrome for Android, the returned Promise
will resolve after the user chooses an application to share to.
navigator.share({ title: document.title, text: 'Hello World', url: 'https://developer.mozilla.org', }); // share the URL of MDN
Specification | Status | Comment |
---|---|---|
Web Share API | Draft |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | No | ? | No | No | No | No |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 61 | 61 | ? | No | 48 | No | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/navigator/share