google.script.host.close关闭对话框不起作用 [英] google.script.host.close to close a dialog box not working

查看:121
本文介绍了google.script.host.close关闭对话框不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var html = HtmlService.createHtmlOutputFromFile('对话框')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(150)
.setHeight(150);
DocumentApp.getUi()。showModelessDialog(html,'Help');

对话框html看起来像这样

 <!DOCTYPE html> 
< html>
< head>
< base target =_ top>
< / head>
< body>
处理它...
< / body>
< / html>

现在我想关闭对话框,但是我无法让它工作。这是我的。

  var html = HtmlService.createHtmlOutputFromFile('close'); 

紧密的html看起来像这样:

 <!DOCTYPE html> 
< html>
< head>
< base target =_ top>
< script>
google.script.host.close();
< / script>
< / head>
< body>
< / body>
< / html>

我试过了google.script.host.close,并且没有'()'。任何想法我做错了什么?



感谢您的时间!

解决方案

据我所知,这是一个相当容易解决的问题。你不想创建一个新的HTML文件来关闭旧的文件,你想关闭第一个。你应该做的是这个。



第二,把你的host.close()在您的help.html中的函数中:

  function closeHelp(){
google.script.host.close ();
};

然后,找到关闭它的地方。我通常只是在任何对话框的底部制作一个按钮。

 < button onclick =closeHelp()>关闭< /按钮> 

这会关闭您的窗口。


I am trying to close a modeless dialog that I opened with the following:

var html = HtmlService.createHtmlOutputFromFile('dialog')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(150)
.setHeight(150);
DocumentApp.getUi().showModelessDialog(html, 'Help');

The dialog html looks like this

<!DOCTYPE html>
  <html>
   <head>
    <base target="_top">
   </head>
    <body>
     Working on it...
   </body>
 </html>

Now I want to close the dialog, but I can't get it to work. This is what I have.

var html = HtmlService.createHtmlOutputFromFile('close');

And the close html looks like this:

<!DOCTYPE html>
 <html>
   <head>
     <base target="_top">
     <script>
       google.script.host.close();
     </script>
   </head>
   <body>
   </body>
 </html>

I've tried the google.script.host.close with the '()' and without. Any ideas what I'm doing wrong?

Thanks for your time!

解决方案

This is a pretty easily fixed issue as far as I can see. You don't want to create a new HTML file to close the old one, you want to close the first one. What you should do is this.

First, open your dialog as you have been doing.

Second, put your host.close() in a function inside of your help.html:

function closeHelp() {
  google.script.host.close();
};

Then, just find somewhere to close it. I normally just make a button at the bottom of any dialog box.

<button onclick="closeHelp()"> Close </button>

This will close your window.

这篇关于google.script.host.close关闭对话框不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆