谷歌应用程序脚本中的Iframe选项
在使用应用程序脚本iframe“X-Frame-Options”开发到“同一来源”时,是否可以在谷歌文档的侧栏中使用iframe显示网站(如www.google.com),出现错误。我尝试了setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) 仍然会发生相同的错误 截图链接 =========== 代码.gs ============= Iframe.html谷歌应用程序脚本中的Iframe选项,iframe,google-apps-script,Iframe,Google Apps Script,在使用应用程序脚本iframe“X-Frame-Options”开发到“同一来源”时,是否可以在谷歌文档的侧栏中使用iframe显示网站(如www.google.com),出现错误。我尝试了setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) 仍然会发生相同的错误 截图链接 =========== 代码.gs ============= Iframe.html 警报(google.script.sandbox.mode);
警报(google.script.sandbox.mode);
请发布一些代码。@布赖恩,我已经编辑了文章。请发布一些代码。@布赖恩,我已经编辑了文章。
function onInstall(e) {
onOpen(e);
}
function onOpen(e){
var ui = DocumentApp.getUi();
ui.createMenu("IframeOptions").addItem("iFrame",'sviFrame').addToUi();
}
function sviFrame(){
var iframe = HtmlService.createHtmlOutputFromFile('Iframe').setSandboxMode(HtmlService.SandboxMode.IFRAME).setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
/*var template = HtmlService.createTemplateFromFile('Iframe')
.evaluate()
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);*/
DocumentApp.getUi().showSidebar(iframe);
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<iframe src="https://www.google.com" height="1500" width="100%"></iframe>
</body>
<script>
alert(google.script.sandbox.mode);
</script>
</html>