This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The Navigator.canShare()
method of the Web Share API returns true
if a call to Navigator.share()
would succeed.
Syntax
var canShare = navigator.canShare(data);
Parameters
data
Optional- An object containing data to share that matches what you would pass to
Navigator.share()
.
Return value
A Boolean
. True if data can be shared with Navigator.share()
.
Exceptions
None.
Examples
if(navigator.canShare(data)) { // We can use share() to share the data! Woop! }
Specifications
Specification | Status | Comment |
---|---|---|
Web Share API - Level 2 The definition of 'canShare' in that specification. |
Draft | Initial definition. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.