【问题标题】:How to fix "Error while parsing the 'sandbox' attribute" flags error with HtmlService?如何使用 HtmlService 修复“解析“沙盒”属性时出错”标志错误?
【发布时间】:2016-02-05 12:58:43
【问题描述】:

我刚刚尝试了很多样例Google Apps Script scripts

但我总是得到错误:

“解析 'sandbox' 属性时出错:'allow-modals'、'allow-popups-to-escape-sandbox' 是无效的沙箱标志。”

我已经尝试在 Mac OS 上使用 Chrome 和 Safari,在 Win 8 上使用 Chrome。

【问题讨论】:

    标签: google-apps-script iframe web-applications


    【解决方案1】:

    可以放心地忽略此错误,脚本将继续正常运行。这是在 Chrome 46(当前稳定版本)中实现的两个新标志。如果您在不支持它们的浏览器中进行测试,您会看到该错误(实际上只是一个警告)。

    allow-modals 标志是必需的,因为默认情况下 Chrome 将使用 block modal dialogs within a sandboxed iframe。添加此标志允许模态在您的应用脚本中工作。

    allow-popups-to-escape-sandbox 标志有点相似;它的目的是permit new windows to be created without them being subject to the same sandboxing restrictions

    【讨论】:

      【解决方案2】:

      这行得通!

      if($('#ssIFrame_google').length) {
        var google_sandbox = $('#ssIFrame_google').attr('sandbox')
        google_sandbox += ' allow-modals'
        $('#ssIFrame_google').attr('sandbox', google_sandbox)
      }
      

      确保在将来自 Google 的 iframe 拉入 DOM 后执行此代码。将 #ssIFrame_google 更改为您的 Google iframe 的任何 ID。

      【讨论】:

        猜你喜欢
        • 2018-07-24
        • 2021-12-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-22
        • 2016-11-13
        • 2019-07-13
        • 1970-01-01
        相关资源
        最近更新 更多