我收到错误“未捕获的 Chrome 网上应用店安装只能通过用户手势启动。”
使用此代码:
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Titre de la page</title>
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/ajhifddimkapgcifgcodmmfdlknahffk">
<script type="text/javascript">
chrome.webstore.install();
</script>
</head>
<body>
test Chrome
</body>
</html>
我不明白为什么我遵循谷歌教程:https://developer.chrome.com/webstore/inline_installation .
有人有想法吗?
谢谢。
最佳答案
来自文档(我将重要部分用斜体表示):
Triggering inline installation
To actually begin inline installation, the
chrome.webstore.install(url, successCallback, failureCallback)
function must be called. This function can only be called in response to a user gesture, for example within a click event handler; an exception will be thrown if it is not.
您不能只将 install()
调用放入脚本标记中并让它自动运行。
关于javascript - 验证安装 chrome 扩展程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46302468/