简体   繁体   中英

Execute callback on Firefox extension installation

I want to provide my users with a link to install a Firefox extension using the InstallTrigger.install. This requires a Javascript object with url as parameter and a optional callback which is executed after the browser handles the action.

According to the MDN documentation this callback is only executed when the user has whitelisted my website. That would be not the case in 99% of the time.

Would there be another way to execute a callback? The main focus is to provide the user a sensible error message when the installation fails or is cancelled.

Firefox simply cannot know whether the installation is canceled. Typically, when you try to install from a third-party site Firefox will show you the message: "Firefox prevented this site from asking you to install software on your computer." Now the user could click "Allow", he could dismiss the message, but he doesn't have to do either. He could also click Alt-Left to go to the previous page - the notification will stay and the installation can still be started but your web page (and any callbacks) will be gone. And even if the user simply dismisses the message: the extension installation icon stays in the URL bar and the notification can be brought back at any time.

So whatever your website needs to do: just do it, don't wait for the user to make a decision. If you want to explain the consequences of denying the installation - explain them. If you want to present alternative ways to install the extension - present them. But don't expect that you will be given a second chance if the user doesn't want to install your extension.

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