google.script.host เป็น JavaScript API ฝั่งไคลเอ็นต์แบบไม่พร้อมกันซึ่งโต้ตอบได้
  ด้วยกล่องโต้ตอบหรือแถบด้านข้างใน Google เอกสาร, ชีต หรือฟอร์มที่มี
  หน้าบริการ HTML เพื่อเรียกใช้ฟังก์ชันฝั่งเซิร์ฟเวอร์จาก
  ในฝั่งไคลเอ็นต์ ให้ใช้ google.script.run สำหรับข้อมูลเพิ่มเติม โปรดดู
  เวลา
  คู่มือการสื่อสารกับฟังก์ชันของเซิร์ฟเวอร์
  ในบริการ HTML
พร็อพเพอร์ตี้
| พร็อพเพอร์ตี้ | คำอธิบาย | 
|---|---|
| origin | ระบุโดเมนโฮสต์ เพื่อให้สคริปต์ตั้งค่า เริ่มต้นอย่างถูกต้อง | 
เมธอด
| วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ | 
|---|---|---|
| close() | void | ปิดกล่องโต้ตอบหรือแถบด้านข้างปัจจุบัน | 
| editor.focus() | void | เปลี่ยนโฟกัสของเบราว์เซอร์จากกล่องโต้ตอบหรือแถบด้านข้างเป็นเครื่องมือแก้ไขของ Google เอกสาร ชีต หรือฟอร์ม | 
| setHeight(height) | void | ตั้งค่าความสูงของกล่องโต้ตอบปัจจุบัน | 
| setWidth(width) | void | ตั้งค่าความกว้างของกล่องโต้ตอบปัจจุบัน | 
เอกสารโดยละเอียด
close()
ปิดกล่องโต้ตอบหรือแถบด้านข้างปัจจุบัน
Code.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 เอกสาร ชีต หรือฟอร์ม
Code.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)
ตั้งค่าความสูงของกล่องโต้ตอบปัจจุบัน
Code.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)
ตั้งค่าความกว้างของกล่องโต้ตอบปัจจุบัน
Code.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 | ความกว้างใหม่เป็นพิกเซล |