google.script.host: 操作可能な非同期のクライアントサイド JavaScript API
  Google ドキュメント、スプレッドシート、フォームのダイアログやサイドバーに
  HTML サービス ページ。サーバー側の関数を
  google.script.run を使用します。詳細については、次をご覧ください:
  
  サーバー機能との通信に関するガイド
  使用できます。
プロパティ
| プロパティ | 説明 | 
|---|---|
| origin | ホストドメインを提供し、スクリプトが自身の URL を 検証できます。 | 
メソッド
| メソッド | 戻り値の型 | 概要 | 
|---|---|---|
| close() | void | 現在のダイアログまたはサイドバーを閉じます。 | 
| editor.focus() | void | ブラウザのフォーカスを、ダイアログまたはサイドバーから Google ドキュメント、スプレッドシート、フォームのエディタに切り替えます。 | 
| setHeight(height) | void | 現在のダイアログの高さを設定します。 | 
| setWidth(width) | void | 現在のダイアログの幅を設定します。 | 
詳細なドキュメント
close()
現在のダイアログまたはサイドバーを閉じます。
コード.gs
function onOpen(e) {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Sidebar').addItem('Show', 'showSidebar').addToUi();
}
function showSidebar() {
  var html = HtmlService.createHtmlOutputFromFile('Index');
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showSidebar(html);
}Index.html
<input type="button" value="Close" onclick="google.script.host.close()" />
editor.focus()
ブラウザのフォーカスを、ダイアログまたはサイドバーから Google ドキュメント、スプレッドシート、フォームのエディタに切り替えます。
コード.gs
function onOpen(e) {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Sidebar').addItem('Show', 'showSidebar').addToUi();
}
function showSidebar() {
  var html = HtmlService.createHtmlOutputFromFile('Index');
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showSidebar(html);
}Index.html
<input type="button" value="Switch focus" onclick="google.script.host.editor.focus()" />
setHeight(height)
現在のダイアログの高さを設定します。
コード.gs
function onOpen(e) {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Dialog').addItem('Show', 'showDialog').addToUi();
}
function showDialog() {
  var html = HtmlService.createHtmlOutputFromFile('Index')
      .setWidth(300)
      .setHeight(200);
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showModalDialog(html, 'Dialog title');
}Index.html
<script>
  function resizeDialog(width, height) {
    google.script.host.setWidth(width);
    google.script.host.setHeight(height);
  }
</script>
<input type="button" value="Resize dialog"
  onclick="resizeDialog(450, 300)" />パラメータ
| 名前 | 型 | 説明 | 
|---|---|---|
| height | Integer | 新しい高さ(ピクセル単位) | 
setWidth(width)
現在のダイアログの幅を設定します。
コード.gs
function onOpen(e) {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Dialog').addItem('Show', 'showDialog').addToUi();
}
function showDialog() {
  var html = HtmlService.createHtmlOutputFromFile('Index')
      .setWidth(300)
      .setHeight(200);
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showModalDialog(html, 'Dialog title');
}Index.html
<script>
  function resizeDialog(width, height) {
    google.script.host.setWidth(width);
    google.script.host.setHeight(height);
  }
</script>
<input type="button" value="Resize dialog"
  onclick="resizeDialog(450, 300)" />パラメータ
| 名前 | 型 | 説明 | 
|---|---|---|
| width | Integer | 新しい幅(ピクセル単位) |