【发布时间】:2012-07-27 17:35:44
【问题描述】:
我正在使用 Google Apps 脚本制作独立的网络应用程序。我在应用程序中有某种任务流程。首先从电子表格中搜索一些内容,然后选择如何处理收集的数据,然后用一些用户输入填充电子表格行。所以我需要在几个州之间奔跑。
我很确定我对网络技术知之甚少,所以这可能是一个非常愚蠢的问题,但它就是这样。
我知道 e.parameters 来自这样的网址 www.google.com&value=helloworld , e.parameters.value 返回 helloworld。
所以现在的问题是:如何在 doGet(e) 中设置参数 e 值并在同一脚本项目中调用同一页面甚至不同的页面/脚本?换句话说,我该如何调用 self&value=helloworld ?
还有其他方法可以做到这一点吗?在 GWT 中,我只是将所有内容存储到数据库中,并将会话保存在 cookie 中。但是不允许使用 cookie,那么如何在 google apps 脚本中保持 webapp 的状态?
编辑:这就是我为 doGet(e) 传递参数的方式。
function doGet(e) {
var app = UiApp.createApplication();
var newValue = 0;
if(e.parameter == undefined || e.parameter.value == undefined){
newValue = 1;
}else{
newValue = 1+parseInt(e.parameter.value);
}
var link = 'https://script.google.com/a/macros/domain.com/s/<insertidhere>/dev';
var anchor = app.createAnchor('Next',link+'?&value='+newValue);
anchor.setTarget('_self');
app.add(anchor);
var label = app.createLabel(newValue);
app.add(label);
return app;
}
链接格式发生了一些变化,因此您需要添加而不是连接 &value=...首先像这样?&value1=helloworld&value2=....
使用失败?导致我认为存在错误,我需要对链接使用旧格式,并且使用旧格式禁止除脚本所有者之外的任何其他人使用它。
希望这可以帮助某人解决类似的问题。
【问题讨论】:
-
像这样将默认链接从新格式更改为旧格式:
New format: /macros/s/{service key}/execOld format: /macros/exec?service={service key}对于 n00bs 来说,Bug 是最糟糕的...