ckn*_*ckn 5 javascript google-chrome-extension
我有一个非常简单的 html 文件,内容如下:
我的页面.html
<html>
<head>
<script language="javascript">
alert(chrome.runtime);
</script>
</head>
<body>
<p>chrome.runtime test</p>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
当我在带有 http 的 Web 服务器中使用此 html 文件时,chrome.runtime 未定义。示例:http://localhost:8080/myapp/mypage.html
但是,如果我在带有 https 的 Web 服务器中使用此 html 文件,则 chrome.runtime 不是未定义的。示例:https://localhost:8080/myapp/mypage.html
背景:我需要使用它来验证是否安装了 chrome 扩展。但是 chrome.runtime 未定义我认为这是不可能的。
另外,我尝试关注其他一些类似的问题,但是在通过 http 而不是 https 打开它时无法正常工作。
为什么 chrome.runtime 在内容脚本中未定义? 为什么 chrome.runtime 未定义?
Chrome:版本 70.0.3538.102(官方版本)(64 位)
| 归档时间: |
|
| 查看次数: |
1250 次 |
| 最近记录: |