首页 > 解决方案 > 忽略对“打印()”的调用。该文档已被沙盒化,并且未设置“allow-modals”关键字 Google App Script

问题描述

我需要制作window.print(),直到昨天才正常工作,现在它在我的浏览器控制台中引发了一个错误:

Ignored call to 'print()'. The document is sandboxed, and the 'allow-modals' keyword is not set

谷歌应用脚​​本和谷歌网站

米码:

<button onclick=" window.print()">Print</button>


function doGet() {

 var output= HtmlService.createTemplateFromFile('index')
      .evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME).addMetaTag("viewport", "width=device-width,height=device-height,initial-scale=1,user-scalable=no").addMetaTag("mobile-web-app-capable", "yes").setTitle("Reforzados")
return output;
}

谁能给我一个可能的解决方案的范围,谢谢

标签: javascriptgoogle-apps-scriptiframeweb-applicationsgoogle-sites

解决方案


Content-Security-Policy 功能,只需在 SecurityHeadersAttribute 文件中添加allow-popups&allow-modals即可正常工作。


推荐阅读