关闭Htmlservice弹出窗口

时间:2019-08-30 13:33:52

标签: google-apps-script popup google-form google-apps-script-web-application

我想知道当在Google表单上点击“提交”按钮时是否可以关闭htmlservice弹出窗口

function launchForm() {
  var form = FormApp.openById('15Qw9jmolybvMbx2d3UhddEWHrKe0zBiV5_asKXolsM0');
  var formUrl = form.getPublishedUrl(); 

//  var response = UrlFetchApp.fetch(formUrl);
//  var formHtml = response.getContentText();

  var htmlApp = HtmlService
      .createHtmlOutput('<h1>Your Organization</h1>')
      .append('<iframe src ="' + formUrl + '?embedded=true" width="1000" height="900" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>')
      .setTitle('Form')
      .setWidth(1000) 
      .setHeight(1000);

  SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
}

我希望当我点击表单上的“提交”按钮时,html应用程序将关闭

1 个答案:

答案 0 :(得分:1)

Google表单将每个页面加载到表单导航或提交。您可以收听这些事件,计算页面加载数量并关闭弹出窗口。

示例:

code.gs:

type TC = ClassTag[T] forSome {type T}
def foo[T](ct: ClassTag[T]) = {}

val tc: TC = classTag[String]
foo(tc)

googleForm.html

function showGoogleForm() {
  var form = FormApp.openById(/*FORM EDIT ID*/);
  var formUrl = form.getPublishedUrl();
  var temp = HtmlService.createTemplateFromFile('googleForm');
  temp.pubUrl = formUrl;
  var htmlApp = temp
    .evaluate()
    .setTitle('Form')
    .setWidth(1000)
    .setHeight(1000);
  SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
}