javascript - 忽略对“打印()”的调用。该文档已被沙盒化,并且未设置“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;
}
谁能给我一个可能的解决方案的范围,谢谢
解决方案
Content-Security-Policy 功能,只需在 SecurityHeadersAttribute 文件中添加allow-popups
&allow-modals
即可正常工作。
推荐阅读
- javascript - 手风琴的“咏叹调角色”应该是什么?在可访问性检查期间,我的手风琴被读取为按钮,这可能会使用户感到困惑
- angular - 用于过滤整个字符串数组的 Ag-grid 文本过滤器
- javascript - vue.js:如何在屏幕上没有呈现任何内容且控制台中没有错误时进行调试。
- python-3.x - 等待消息不和谐 python 3.6
- python - 如何使用 python 打开类似 vim、类似手册页的隔离显示?
- google-chrome - 为什么在启用 HTTP2 协议后 Chrome 调试器中的请求仍在排队?
- c - 如何去除C语言字符串末尾重复多次的重复字符?
- amazon-web-services - Terraform 读取现有资源的详细信息
- php - 如何从laravel中的先前记录中获取数据
- php - 如何在 PHPWord 中对文本框应用无填充