ReferenceError: google is not defined - Google Apps script error in Mozilla firefox

孤街浪徒 提交于 2021-02-10 21:58:56

问题


I'm creating a Google Site with Google Apps Script "Enum Sandbox Iframe mode".

In Google Developer Docs, It says, to call a custom function, we need to use google.script.run

Sample:

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>

When I run this using Google Chrome, Its working perfect. But it throws an error in Mozilla Firefox. ReferenceError: google is not defined.

Does anyone know the reason behind it? Any help would be appreciated.

Update:

Filed a bug in Google Code : https://code.google.com/p/google-apps-script-issues/issues/detail?id=4652&thanks=4652&ts=1419836713&


回答1:


IFRAME mode is not supported in all browsers

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

You have to switch to EMULATED or NATIVE for now. IFRAME mode is new, maybe more support will come for this with time.

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


来源:https://stackoverflow.com/questions/27684512/referenceerror-google-is-not-defined-google-apps-script-error-in-mozilla-fire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!