- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个简单的页面,其中包含我通过 AJAX 请求处理的一些详细信息。
在 AJAX 调用成功回调时,我试图触发 navigator.share
这给了我一个错误:
NotAllowedError: Must be handling a user gesture to perform a share request.
$("#form-button").on('click', function (event) {
var ele = $(this);
event.preventDefault();
$.ajax({
// ...
dataType: "json",
data: { "foo": "bar" },
success: function (response) {
if (navigator.share) {
navigator.share({
title: response.text,
text: response.text,
url: response.href
}).then(function () {
alert('Successful share')
}).catch(function (error) {
alert('Error sharing: ' + error);
});
}
},
});
});
... you can only invoke the API in response to a user action, such as a click (e.g., you can't call navigator.share as part of the page load)
navigator.share
,它可以工作在点击事件下,但不是当我把它放在 AJAX 回调中时。我希望 API 会检查事件链。
最佳答案
Chromium 目前似乎显示了拒绝数据类型的错误错误消息,例如尝试共享 pdf 文件;也不允许共享 JSON 文件。
Chromium 拒绝“共享”的其他情况也可能会给您同样的错误消息。例如,在我的情况下,我在本地测试(file://...)或使用“http”而不是“https”。
请参阅我在其中找到此信息的这条推文:
https://twitter.com/daviddalbusco/status/1344641231184396288
并且允许的文件扩展名列表在那里:
https://docs.google.com/document/d/1tKPkHA5nnJtmh2TgqWmGSREUzXgMUFDL6yMdVZHqUsg/
[编辑]
我确认相同的代码在移动 Chrome 上运行良好,但在桌面 Chrome 89 上失败,如下所示:
关于jquery - NotAllowedError : Must be handling a user gesture to perform a share request. navigator.share,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56136692/
更新3 无奈之下,我创建了一个新的google appengine应用,该应用与原始应用相同,即使名称相同,但ID稍长。新应用程序具有-232619 added to the ID,原始应用程序具有简
我正在使用 ar.js,它使用用户网络摄像头并发出权限提示。我想要的是在用户允许或拒绝访问网络摄像头或之前已经这样做的情况下收听此对话触发的全局事件。 我试过像这样的全局听众: document.d
我突然得到一个 navigator.MediaDevices.getUserMedia notAllowedError 我不是一个月前。没有代码改变。我正在使用火狐 68.01。当我在 AWS 上运行
我尝试将主页 '/' 设置为用户登录或不登录,但我得到了一个NotAllowedError。这适用于本地服务器。但是,在真正的公用服务器中似乎不起作用。 NotAllowedError 是否意味着遵守
我们正在尝试制作视频 session 应用程序。在 Windows 上运行该应用程序进行测试时,视频打开得很好,但是当我们在物理设备(Android 手机)上运行它时,出现以下错误并且视频不显示。 E
我有一个简短的问题。当我按下一个使用 ajax 请求将数据获取到剪贴板的按钮时,我想在我的 iOS 设备上的剪贴板上添加一个文本。 使用我桌面上的浏览器和我的 Android 设备,它运行良好,但使用
我有一个带有按钮的简单页面,按下该按钮时,它使用异步剪贴板 API 写入剪贴板。 Test Clipboard function testClipboard() { nav
自上次 Safari 更新到版本 11 以来,一些视频停止播放。最糟糕的是,有时,就像五次尝试中一次,它会奏效。我认为原因是我的 JS 脚本集成了 Vimeo Player API,但结果是 Vime
我有一个正在制作的网站,这是一个非常旧的网站,我对彻底改造不感兴趣。 我有一个 Controller ,可以从 soundcloud 播放列表中获取一堆轨道,以及一些循环播放它们的代码
我有一个套件可以记录用户的网络摄像头和麦克风。它在网页上运行良好,但在 Chrome 扩展程序中: navigator.mediaDevices.getUserMedia({video: true,
基于 How-to guide 中的示例代码,我在 Google App Engine 中使用 users.create_login_url 的一个非常基本的示例遇到了问题。 .该示例在本地开发服务器
我的问题的沙盒演示:https://codesandbox.io/s/jolly-fermat-j23w9 我正在尝试在我的 React 网站上实现一个功能,用户点击一个元素,然后播放音频。 在桌面上
我有一个简单的页面,其中包含我通过 AJAX 请求处理的一些详细信息。 在 AJAX 调用成功回调时,我试图触发 navigator.share这给了我一个错误: NotAllowedError: M
我正在尝试开发一个 Chrome 扩展来访问网络摄像头并录制视频,并在停止后下载它。 扩展失败,调用以下代码行时出错: navigator.mediaDevices.getUserMedia({ au
客观化。预期行为:按下复制按钮后,文本将复制到手机剪贴板中。当前行为:按下复制按钮后,Ffltter InAppWebView抛出错误未捕获(在Promise中)NotAlledError:写入权限被
我是一名优秀的程序员,十分优秀!