How to pass a parameter to html?

前端 未结 5 1713
小鲜肉
小鲜肉 2020-11-28 13:01

I have a script that uses the file picker but I need to pass a specific parameter which is called userId and is kept as a global variable in the calling script.

5条回答
  •  Happy的楠姐
    2020-11-28 13:49

    By Appending to the HTML File, as shown below.

    within Code.gs

    function showDialog() {
        var html = HtmlService.createHtmlOutputFromFile('html-sample')
                    .setSandboxMode(HtmlService.SandboxMode.IFRAME)
                    .setWidth(600)
                    .setHeight(425);
    
        var data = "Hello World!";
        var strAppend = "";
        html.append(strAppend);
    
       var title = "Demo";
       SpreadsheetApp.getUi().showModalDialog(html, title); // or DocumentApp or SlidesApp or FormApp.
    }
    

    html-sample.html

    
    
       
          
       
       
          

    Sample Text

    Click the 'Try Now!' Button and See the Magic!

提交回复
热议问题