gpt4 book ai didi

javascript - 引用错误 : google is not defined - Google Apps script error in Mozilla firefox

转载 作者:行者123 更新时间:2023-11-30 12:31:04 24 4
gpt4 key购买 nike

我正在使用 Google Apps 脚本“Enum Sandbox Iframe mode”创建一个 Google 站点。

Google Developer Docs , 它说,要调用自定义函数,我们需要使用 google.script.run

示例:

Code.gs

function doGet() {  return HtmlService.createHtmlOutputFromFile('index')      .setSandboxMode(HtmlService.SandboxMode.IFRAME);}function doSomething() {  Logger.log('I was called!');}

index.html

<script>  google.script.run.doSomething();</script>

当我使用谷歌浏览器运行它时,它运行完美。但它会在 Mozilla Firefox 中引发错误。 ReferenceError: google 未定义

有人知道背后的原因吗?任何帮助将不胜感激。

更新:

在谷歌代码中提交了一个错误:https://code.google.com/p/google-apps-script-issues/issues/detail?id=4652&thanks=4652&ts=1419836713&

最佳答案

并非所有浏览器都支持 IFRAME 模式

This mode imposes many fewer restrictions than the other sandbox modes and runs fastest, but does not work at all in certain older browsers, including Internet Explorer 9

https://developers.google.com/apps-script/reference/html/sandbox-mode

您现在必须切换到 EMULATED 或 NATIVE。 IFRAME 模式是新的,也许随着时间的推移会有更多的支持。

function doGet() {
return HtmlService.createHtmlOutputFromFile('index')
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
}

关于javascript - 引用错误 : google is not defined - Google Apps script error in Mozilla firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27684512/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com