【发布时间】:2014-04-19 01:54:47
【问题描述】:
我正在使用Google JavaScript Client Library 加载一些通过Google Cloud Endpoints 公开的API 的网站。端点是用 Python 开发的,但我不确定这是否是一个因素。在 Chrome、Firefox 和 Safari 中一切正常,但在 Internet Explorer 10 上出现此错误:
SCRIPT5007: Unable to get property 'value' of undefined or null reference
proxy.html, line 7 character 51
我正在使用类似于suggested by Google in their documentation 的代码加载客户端库:
<script type="text/javascript">
Oversee.Init();
function init() {
console.log("starting to load endpoints");
gapi.client.load("marketplace", "1", function() {
console.log("finished loading endpoints");
}, "//" + window.location.host + "/_ah/api");
}
</script>
<script type="text/javascript" src="https://apis.google.com/js/client.js?onload=init"></script>
这会在控制台上输出以下内容:
starting to load endpoints
SCRIPT5007: Unable to get property 'value' of undefined or null reference
proxy.html, line 7 character 51
请注意,“完成加载端点”这一行永远不会输出。
经过漂亮的打印后,proxy.html 中的代码看起来是这样的,特别是 document.getElementById('root').value,因为 document.getElementById('root') 为 null 或未定义。
gapi.load('googleapis.proxy', {
callback: function () {
return window['googleapis']['server']['initWithPath']
.call(this, document.getElementById('root').value);
},
config: {
// snipped
}
});
我注意到,如果我重新加载页面,api 加载成功,控制台输出如下:
starting to load endpoints
finished loading endpoints
当我使用本地开发服务器和使用托管在生产 Google App Engine 实例上的应用时,上述所有情况都会发生。
有没有人成功地从 Internet Explorer 10 调用 Google Cloud Endpoints?如果是这样,我的代码中缺少什么?
编辑:Google's example Cloud Endpoints web app 也出现了问题。我在这里部署了它的一个副本:https://cloud-endpoints-demo.appspot.com,在 Internet Explorer 10 上运行它时也会出现同样的错误。
编辑 2: 我在这里创建了一个问题:https://code.google.com/p/googleappengine/issues/detail?id=10700
编辑 3:Google's TicTacToe example for cloud endpoints 中也出现此问题。我在这里部署了一个副本:https://cloud-endpoints-tictactoe.appspot.com;与其他演示一样,它在 Chrome 和 Safari 上运行良好,但在 Internet Explorer 10 上以同样的方式失败。
编辑 4: 我仔细查看了 Google 提供的 proxy.html。在导致错误的脚本标记下方,有这个正文,其中包含一个 id 为“root”的文本区域:
<body>
<textarea id="root" style="display:none">/_ah/api</textarea>
<div id="lcsclient" style="position:absolute;left:-10000px;"></div>
</body>
因此,Google 似乎需要对 proxy.html 进行一些更改,以确保该文档在 javascript 在 Internet Explorer 上执行之前已加载 - 我说的对吗?
【问题讨论】:
标签: javascript internet-explorer google-app-engine internet-explorer-10 google-cloud-endpoints