Google Apps Script not working in Chrome

2020-07-27 08:17发布

I have a simple test google apps script that prints the content of a sheet. It works fine in Safari on Mac but on Chrome I get a blank page with this error in the console:

dropping postMessage.. was from unexpected window

This is the code:

    function doGet() {
  return HtmlService
      .createTemplateFromFile('index')
      .evaluate();
}

function getData() {
  return SpreadsheetApp
      .openById('1vyrKW7ABfCDY-a8H4AZ2JFZwA7lpCEuD6R5x4fJ8_qI')
      .getActiveSheet()
      .getDataRange()
      .getValues();
}

Here is the HTML template:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <? var data = getData(); ?>
    <table>
      <? for (var i = 0; i < data.length; i++) { ?>
        <tr>
          <? for (var j = 0; j < data[i].length; j++) { ?>
            <td><?= data[i][j] ?></td>
          <? } ?>
        </tr>
      <? } ?>
    </table>
  </body>
</html>

And here is the published web app: https://script.google.com/macros/s/AKfycbyYiAlqtqElFeyiWD6yq2zWtzQ1vdJMkHUPOfZrQFvicTO_uXs/exec

1条回答
混吃等死
2楼-- · 2020-07-27 08:35

It is a known issue with the latest version of Google Chrome. If you open the web app inside Firefox, it would work just fine.

Please star this issue on code.google.com for updates.

查看更多
登录 后发表回答