我的脚本对象是在电子表格中打开一个Html窗口并选择任何按钮,然后在运行脚本后单击一个特定按钮。
除了一个额外的步骤之外,我的脚本会执行所有操作。每次进行选择时,它都会打开一个空白窗口。
这是我的HTML代码: -
var IdList = new List<int>();
do
{
billId = random.Next(1, 9000);
} while (IdList.Contains(billId));
IdList.Add(billId);
这是我的应用脚本: -
<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>
如果我做出任何选择,你能告诉我为什么会弹出一个奇怪的空白浏览器窗口吗?我的功能完全正常运行。
答案 0 :(得分:0)
当GAS端的这些功能(Zoom(), AIURUN(), TOPSKURUN(), QARUN()
)工作正常时,不会发生错误。窗户没有留下。在你的问题中,你说这些工作正常。
所以我看到了你的脚本编辑器。结果发现原因是<base target="_top">
。 _top
表示取消框架显示,并在整个窗口中显示链接目标页面。所以请修改如下。
<base target="_top">
<base target="_self">
OR
<base href="" target="_top">