简体   繁体   中英

is there any way to get the “Allow” button click event in “Allow to use microphone popup”(chrome latest)?

i am trying to figure out how could i get the event of the "Allow" button and "Cancel" which pops up near the TLS lock icon, i searched online but couldn't found any articles on this in javascript?

i am using chrome speechrecognition API Does anyone have any idea?

I don't think you can get the buttons events.

You can, however, detect the change in permission using the Permission API

Here's an example:

navigator.permissions.query(
    { name: 'microphone' }
).then(function(permissionStatus){
    console.log("Current state: " + permissionStatus.state)

    permissionStatus.onchange = function(){
      if (this.state == "granted") {
        console.log("Allow");
      } else if (this.state == "denied") {
        console.log("Block");
      } else if (this.state == "prompt") {
        console.log("Ask");
      }
    }
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM