javascript - 函数 openDialog() 设置宽度和设置高度 Google 电子表格

标签 javascript html css google-apps-script google-sheets

我需要设置 dialog in a Google Spreadsheet 的宽度.

到目前为止我的代码是:

// Use this code for Google Docs, Forms, or new Sheets.
function onOpen() {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Cadastro')
      .addItem('Open', 'openDialog')
      .addToUi();
}

function openDialog() {
  var html = HtmlService.createHtmlOutputFromFile('index');
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showModalDialog(html, 'Dialog title');
}`enter code here`

最佳答案

这将设置您的高度和宽度。

function openDialog() {
  var html = HtmlService.createHtmlOutputFromFile('index')
  .setHeight(100)
  .setWidth(100);
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp
  .showModalDialog(html, 'Dialog title')
  }//`enter code here`

当然,您还需要将index.html文件添加到脚本编辑器,例如:

Hello, world! <input type="button" value="Close" onclick="google.script.host.close()" />

关于javascript - 函数 openDialog() 设置宽度和设置高度 Google 电子表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39638525/

相关文章:

html - IE8 和 IE9 中 <p> 和 <h2> 的文本呈现问题

html - margin :auto; won't work even after width is specified?

javascript - 当用户滚动时,我希望 div 在页面底部滚动

javascript - 使用唯一成员的 Firebase 数据收集

javascript - 以不同模式从添加到企业站点列表的站点打开特定页面

html - 如何使用 CSS 将此表单居中放置在页脚中?

javascript - Hide::before 悬停在事件元素上

javascript - 为什么 JavaScript Closure 返回 undefined

javascript - 正则表达式编号以 0 开头或什么都不允许

html - Firefox 中的 hsl 颜色问题