我正在尝试添加一个利用本机Web Share API的共享按钮,以检查我正在使用的支持
if ('share' in window.navigator)
但是Edge不支持时会返回一个函数,而Chrome会正确返回undefined。
https://caniuse.com/#feat=web-share
关于如何以及如何解决这个问题的任何想法?
if ('share' in window.navigator) {
console.log(window.navigator);
console.log("true");
}
else {
console.log("false");
}
经过测试,上面的脚本在Edge浏览器(Edge和Edge Chromium的旧版)浏览器和Chrome浏览器中运行良好,用于检查window.navigator对象或其原型中的share属性,更多详细信息,请检查in operator。
关于Web Share API的navigator.share() method,它不支持Edge和Chrome浏览器,请检查文档示例和浏览器兼容性。