【问题标题】:Blank Window Opening when running google Spreadsheet script运行谷歌电子表格脚本时打开空白窗口
【发布时间】:2017-11-03 07:47:45
【问题描述】:

我的脚本对象是在电子表格中打开一个 Html 窗口并选择任何按钮,然后在脚本应该运行后一旦单击特定按钮。

除了一个额外的步骤,我的脚本执行所有操作,每次我进行选择时它都会打开一个空白窗口。

这是我的 HTML 代码:-

<script> 

window.addEventListener('load', displayButtons());

function displayButtons(){
document.getElementById("myForm").innerHTML+='<button style="margin-right:4px;" onclick="google.script.run.withSuccessHandler(google.script.host.close).FULLFEED();">FULL FEED</button>';
document.getElementById("myForm").innerHTML+='<button style="margin-right:4px;" onclick="google.script.run.withSuccessHandler(google.script.host.close).AIU();">Automatic Item Update</button>'; 
document.getElementById("myForm").innerHTML+='<button style="margin-right:4px;" onclick="google.script.run.withSuccessHandler(google.script.host.close).TOPSKU();">TOP SKU</button>';
document.getElementById("myForm").innerHTML+='<button style="margin-right:4px;" onclick="google.script.run.withSuccessHandler(google.script.host.close).LIA();">LIA</button>'; 
document.getElementById("myForm").innerHTML+='<button style="margin-right:4px;" onclick="google.script.run.withSuccessHandler(google.script.host.close).QA();">Quality Analysis</button>';
}

</script>

这是我的应用程序脚本:-

function Popup() {
var html = HtmlService.createHtmlOutputFromFile('Index5');
SpreadsheetApp.getUi()
   .showModalDialog(html, 'Select Procedure');
var ss = SpreadsheetApp.getActiveSpreadsheet();
html.setHeight(600).setWidth(288);
ss.show(html);
}


function FULLFEED()
{ Zoom(); }

function AIU()
{ AIURUN(); }

function TOPSKU()
{ TOPSKURUN(); }


function LIA()
{ LIARUN(); }

function QA()
{ QARUN();  }

如果我做出任何选择,请告诉我为什么会弹出一个奇怪的空白浏览器窗口,仅供参考,我的功能运行良好。

【问题讨论】:

  • 这里应该做的是link到你想看的电子表格。

标签: html google-apps-script google-sheets


【解决方案1】:

当这些功能(Zoom(), AIURUN(), TOPSKURUN(), QARUN())在 GAS 端正常工作时,不会出现错误。并且窗口没有离开。在您的问题中,您说这些工作正常。

所以我看到了你的脚本编辑器。发现原因是&lt;base target="_top"&gt;_top 表示取消框架显示,整个窗口显示链接目标页面。所以请修改如下。

发件人:

<base target="_top">

收件人:

<base target="_self">

<base href="" target="_top">

参考:

【讨论】:

  • 谢谢田池!我非常感谢您的努力,它现在有效。
  • @Sharad Gurung 也谢谢你。
猜你喜欢
  • 2015-01-02
  • 2017-06-19
  • 1970-01-01
  • 2023-03-19
  • 2012-06-15
  • 2012-12-30
  • 2015-08-16
  • 1970-01-01
相关资源
最近更新 更多