我有一个显示 html 表单的模式。该表格有一个按钮。 模态最初设置为 600x425 的宽度。然后在运行时,如果按下按钮,它应该将模式大小从 600x425 调整为 300x200。
如何使用 Google Apps 脚本获取此内容
function showPickerImages() {
var html = HtmlService
.createTemplateFromFile("MyHTMLForm")
.evaluate()
.addMetaTag("viewport", "width=device-width, initial-scale=1")
.setWidth(600)
.setHeight(425)
.setTitle("Resize demo")
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
SpreadsheetApp.getUi().showModalDialog(html, 'demo');
}
MyHTMLForm.html
<button onclick="resizeModalDialog()"></button>
最佳答案
使用google.script.host.setWidth(width)
和 setHeight
:
// resize modal window
function resizeModalDialog()
{
google.script.host.setWidth(300);
google.script.host.setHeight(200);
}
关于javascript - 在运行时使用 GAS 调整 HTML 模态的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47471447/