如何修复 HtmlService 的 "Error while parsing the 'sandbox' attribute" 标志错误?
How to fix "Error while parsing the 'sandbox' attribute" flags error with HtmlService?
我刚刚尝试了很多样例Google Apps Script scripts
但我总是得到错误:
"Error while parsing the 'sandbox' attribute: 'allow-modals', 'allow-popups-to-escape-sandbox' are invalid sandbox flags."
我已经尝试在 Chrome 和 Safari 上 Mac OS 和 Chrome 在 Win 8 上。
可以安全地忽略此错误,脚本将继续 运行 正常。这是在 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.
这行得通!
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。
我刚刚尝试了很多样例Google Apps Script scripts
但我总是得到错误:
"Error while parsing the 'sandbox' attribute: 'allow-modals', 'allow-popups-to-escape-sandbox' are invalid sandbox flags."
我已经尝试在 Chrome 和 Safari 上 Mac OS 和 Chrome 在 Win 8 上。
可以安全地忽略此错误,脚本将继续 运行 正常。这是在 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.
这行得通!
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。