Cod*_*Guy 1 html javascript google-sheets google-apps-script
我有一个显示 html 表单的模式。该表格有一个按钮。模态最初设置为 600x425 的宽度。然后在运行时,如果按下按钮,它应该将模式大小从 600x425 调整为 300x200。
我如何使用谷歌应用程序脚本得到这个
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');
}
Run Code Online (Sandbox Code Playgroud)
MyHTMLForm.html
<button onclick="resizeModalDialog()"></button>
Run Code Online (Sandbox Code Playgroud)
使用google.script.host.setWidth(width)和setHeight:
// resize modal window
function resizeModalDialog()
{
google.script.host.setWidth(300);
google.script.host.setHeight(200);
}
Run Code Online (Sandbox Code Playgroud)