Navigator.canShare

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

如果对Navigator.share() 的调用成功,则Web Share API的Navigator.canShare()方法将返回true。

语法

var canShare = navigator.canShare(data);

参数

data 可选
包含要共享的数据的对象,该对象要与Navigator.share()方法传递的数据相匹配。

返回值

Boolean值. Navigator.share()若返回True则表示内容可以被成功分享。

规范

Specification Status Comment
Web Share API - Level 2
canShare
Draft Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
canShare
ExperimentalNon-standard
Chrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android Full support 75Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android Full support 11.0

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.

相关连接

navigator.share()