1
votes

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

1 Answers

3
votes

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);
}