Multi-page site in Google Apps Script: How to invoke doGet() through jquery or javascript?

前端 未结 2 1711
无人及你
无人及你 2021-01-07 09:37

I want to build multi-page sites using Google Apps Script. To do this, I would like to exploit the ability of doGet() to process query strings. I am aware of at

2条回答
  •  离开以前
    2021-01-07 10:21

    Here's what I ended up using in the basic html page:

    
    
      
        Speedgolf Scoring
        
        
      
      
        

    Please choose interface:

    And my gs code now looks like this:

    function getScriptURL(qs) {
    
      var url = ScriptApp.getService().getUrl();
      Logger.log(url + qs);
      return url + qs ;
    }
    
    
    function doGet(e) 
    {
      Logger.log('query params: ' + Utilities.jsonStringify(e));
      if(e.queryString !=='')
      {  
        switch(e.parameter.mode)
        {
          case 'onesheet':
            return HtmlService
            .createHtmlOutputFromFile('onesheet')
            .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
            .append('
    onesheet') .setTitle("One Sheet"); break; case 'allsheets': return HtmlService .createHtmlOutputFromFile('allsheets') .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) .append('
    allsheets') .setTitle("All Sheets"); break; default: return HtmlService .createHtmlOutputFromFile('speedgolferah') .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) .append('
    No Query String') .setTitle("Main Page"); break; } } else { return HtmlService .createHtmlOutputFromFile('speedgolferah') .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) .append('
    No Query String') .setTitle("Main Page"); } }

    I have some other pages I threw in because I had them. One displays all of my sheets and one displays just the one I select. But yeh I'd been putting this off for a while and I was good to get in there and start messing with the multiple payge solution for the doGet again.

    But thanks for the window.open(url,"_top"); that made a lot of difference. Thanks.

提交回复
热议问题