如果用户第一次拒绝,我想重新提示相机许可。
代码:
navigator.mediaDevices.getUserMedia({video: true, audio: false}).then(function(){
document.getElementById("submitbutton").style.display="inline";
}).catch(function(err){alert("Please provide consent.");location.reload();});
Run Code Online (Sandbox Code Playgroud)
上面的代码在我第一次拒绝权限后重新加载页面。但重新加载后,它不会提示许可,而是再次进入 .catch 块
我相信发生这种情况是因为浏览器第一次存储被拒绝的承诺,并在页面重新加载时检查相同的承诺。
有什么办法可以强制再次出现权限提示吗?