Run google web apps script alright in dev mode but

2019-09-16 06:35发布

问题:

I have a script project called displayhtmlfromquerystring,

the script file is

function doGet(e){
  var html;
  if(e.parameter.html)
    html=e.parameter.html;

  else
    html="Error no html";

    return HtmlService.createHtmlOutput(html+"<hr/>");
}

I have deployed it as web apps, google gave me two links, one ends with "dev" and one ends with "exec".

When run script with dev link, it is alright but when run with exec link the page displayed the only word "undefined", I got stuck, could any one tell me why?

Link of my script app "https://script.google.com/macros/s/AKfycbyinAHBmjVgKDinY-bCcwQ4bgy87KuibiflG1158qRkBJSSXeMk/exec"

回答1:

The /dev links only work when you are logged in your Google account.

When making any changes to your code, you should go to Publish > Deploy As Web App, select a new version and click Update.

Now the latest changes would be available on the /exec page as well.



回答2:

It's working for me when I use your code:

function doGet(e) { // main function
    var html;
  if(e.parameter.html)
    html=e.parameter.html;

  else
    html="Error no html";
    return HtmlService.createHtmlOutput(html+"<hr/>");
}