0

app.close() は何もしませんか? 動作していないようです.... // Script-as-app テンプレート。サンプルコード

function doGet() {
  var app = UiApp.createApplication();

  var button = app.createButton('Click Me');
  var closeButton = app.createButton('Close It');
  app.add(closeButton);
  app.add(button);

  var label = app.createLabel('The button was clicked.')
                 .setId('statusLabel')
                 .setVisible(false);

  var label2 = app.createLabel('The Close button was clicked.')
                 .setId('statusLabel2')
                 .setVisible(false);
  app.add(label);
  app.add(label2);
  var closeHandler = app.createServerHandler('close');
  closeHandler.addCallbackElement(label);
  var handler = app.createServerHandler('myClickHandler');
  handler.addCallbackElement(label);
  closeButton.addClickHandler(closeHandler);
  button.addClickHandler(handler);

  return app;
}

function myClickHandler(e) {
  var app = UiApp.getActiveApplication();

  var label = app.getElementById('statusLabel');
  label.setVisible(true);

  app.close();
  return app;
}
function close(e)
{
  Logger.log("Here");
  var app = UiApp.getActiveApplication();
  var label2 = app.getElementById('statusLabel2');
  label2.setVisible(true);
  return app.close();
}

サンプル コードへのリンク https://script.google.com/a/macros/scotts.com/s/AKfycbz-avIT3bZNJ68_EpRZYXmh66XLJzYI--F0n7DGNn8jL_wlG1k/exec

4

1 に答える 1

0

ここに文書化されているように:

「これは、アプリが Google スプレッドシートなどのダイアログとして表示されている場合にのみ機能します。スタンドアロン サービスとして公開されているアプリで呼び出された場合は効果がありません。」

ちなみに、これはブラウザの基本的な制限です。ページを閉じることはできません。

于 2012-11-08T19:17:46.530 に答える