- Learning Google Apps Script
- Ramalingam Ganapathy
- 135字
- 2021-07-16 12:40:04
Creating a sidebar
A sidebar is a static dialog box and is included on the right-hand side of the document editor window. To create a sidebar, type the following code in the editor:
function onOpen() { var htmlOutput = HtmlService .createHtmlOutput('<button onclick="alert(\'Hello World!\');">Click Me</button>') .setTitle('My Sidebar'); DocumentApp.getUi().showSidebar(htmlOutput); }
In the preceding code, you are using HtmlService
and invoking its method createHtmlOutput
then consecutively invoking the setTitle
method. To test this code, run the onOpen
function or reload the document. The sidebar will open in the right-hand side of the document window as shown in the following screenshot. The sidebar layout size is a fixed one, which means you cannot change, alter, or resize it.

The button in the sidebar is an HTML element, not a GAS element, and if clicked, it opens the browser interface's alert box.
推薦閱讀
- Kibana Essentials
- Docker and Kubernetes for Java Developers
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- 程序員面試算法寶典
- 匯編語言程序設計(第2版)
- Learning Hunk
- Learning Three.js:The JavaScript 3D Library for WebGL
- 編程數學
- Spring Security Essentials
- Apache Camel Developer's Cookbook
- 深入理解BootLoader
- OpenCV Android開發實戰
- Node.js 6.x Blueprints
- Mastering Machine Learning with R
- ANSYS FLUENT 16.0超級學習手冊