0
我使用Google Apps脚本边栏插入文本,在那里我输入需要一些文字开头追加,然后再键入追加后。传递换行符作为变量insertText气体
所附文本将通过在侧边栏文本框来确定。
我传递值formObject
function sendform(){
var f = document.forms[0].elements;
var data = { "mytext": f[0].value }
google.script.run.withSuccessHandler(ready).withFailureHandler(onFailure).processForm(data);
}
下面是应用脚本代码。
function processForm(fO)
{
var body = DocumentApp.getActiveDocument().getBody();
body.editAsText().insertText(0, "\n\nsometext");
// this will perfectly insert the newlinenewlinesometext to the document
body.editAsText().insertText(0, fO.mytext);
// this will insert \n\nsometext which is wrong
}
我试着用encodeURIComponent方法decodeURIComponent,但它仍然同样的问题。
有什么建议吗?