我在Chrome扩展程序中使用了Channel API.
在Google App Engine渠道API Javascript参考(Python)页面中,它说明了这一点
在引用它的任何JavaScript代码之前,在您的html页面中包含以下内容:
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
Run Code Online (Sandbox Code Playgroud)
所以,我把它放在我的options.html文件的标题中:
<html>
<head>
<title>Extension Options</title>
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
</head>
Run Code Online (Sandbox Code Playgroud)
但Chrome会抛出jsapiFailed to load resource错误.我究竟做错了什么?
更新
根据Moishe的回答,我更新了对jsapi的调用,如下所示:
<head>
<title>Extension Options</title>
<!-- this does not work because it is local
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
-->
<script type="text/javascript" src="https://talkgadget.google.com/talkgadget/channel.js"></script>
</head>
Run Code Online (Sandbox Code Playgroud)
更新
我添加了onopen其他属性.现在我收到onopen警报,但我没有得到evt.data警报.我究竟做错了什么?
<html>
<head>
<title>Extension Options</title>
<!-- this does not work because it is local url
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
-->
<script type="text/javascript" src="https://talkgadget.google.com/talkgadget/channel.js"></script>
</head>
<body> …Run Code Online (Sandbox Code Playgroud)