官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 台州市| 玉山县| 汤阴县| 织金县| 洮南市| 鄯善县| 洛扎县| 安义县| 眉山市| 昭苏县| 进贤县| 调兵山市| 钟祥市| 贵阳市| 瓮安县| 普宁市| 汉沽区| 东兰县| 三台县| 都江堰市| 仪陇县| 巫山县| 常德市| 固阳县| 德阳市| 宁晋县| 马尔康县| 临沂市| 庆阳市| 河源市| 延津县| 泌阳县| 阿鲁科尔沁旗| 镇江市| 奉贤区| 绵竹市| 波密县| 旅游| 隆子县| 咸丰县| 万载县|