javascript - navigator.share 在移动浏览器中不起作用(chrome v64)

标签 javascript android-intent mobile-chrome

我一直在尝试使用 navigator.share 从 javascript 触发 Android 浏览器中的 Intent Share .

以下是示例代码:

$("#printTest").click(function(e){
    if (navigator.share === undefined){
        alert('Undefined!');
    }
    else{
        alert('Sharing!');
        navigator.share({title: 'Example Page', text: 'https://example.com'});
    }
});

当我尝试在 ubuntu 中单击 chrome 中的按钮时,它会打开一个共享窗口(虽然没有显示任何应用程序可供选择)。但同样不适用于任何 android 移动浏览器。我已经在 Chrome for Android 64 版和 Chrome for Android Dev 中进行了测试。即使在启用标志 chrome://flags/#enable-experimental-web-platform-features 后,所有的都显示警报“未定义”。 .

最佳答案

navigator.share仅适用于具有 https 的网站而不是 HTTP

关于javascript - navigator.share 在移动浏览器中不起作用(chrome v64),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48802255/

相关文章:

android - 使用预装的谷歌地图而不是使用 Intents 自己的 Activity ?

css - Chrome 移动设备中的错误视口(viewport)

javascript - iOS 12 Safari 的私有(private)/隐身模式检测

javascript - Websockets onMessage 函数 : What happens if the code block within onMessage takes longer to run than interval between two messages?

javascript - Node 套接字挂断错误与http

javascript - 如何让这个功能发挥作用?

java - 是否可以使用 Activity 名称或类似名称在 Android 上使用 startActivity 在不同的 apk 中启动 Activity ?

android - 将应用程序与 Google 搜索结果和 Chrome 集成

javascript - Sortablejs 根据与边缘的距离自动滚动速度

javascript - 浏览器可以在关闭后重新启动 Web 应用程序安装横幅(chrome 添加到主屏幕)吗?