google-apps-script -\n在Google Apps脚本Browser.msgBox中不起作用

标签 google-apps-script

我正在尝试以下将换行符添加到消息框,但是它不起作用。

function showMsgBox(){
  var msg = 'name: \n \n \n Doc URL';
  Browser.msgBox("Selected Doc template:", msg, Browser.Buttons.OK);
}

我不要单引号或双引号。

我也尝试过Browser.msgBox(msg);,但是都一样。

我究竟做错了什么?

谢谢。

最佳答案

由于历史原因,您需要两次转义“\ n”

function myFunction() {
  Browser.msgBox("Hello\\nWorld")
}

关于google-apps-script -\n在Google Apps脚本Browser.msgBox中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12804502/

相关文章:

javascript - 气体 : how to adapt this piece of code to change cell value only if it's empty?

google-apps-script - 如何删除Google Apps脚本服务

javascript - 通过 Google Apps 脚本 POST 到 Todoist API 时出现 HTTP 错误 "AUTH_CSFR_ERROR"

javascript - 仅在触发时(而不是在测试时)因 indexOf 导致脚本失败

javascript - Google 脚本/将执行时间减少到执行时间限制以下

google-apps-script - 我需要通过Google Web表单将IP地址捕获到Google电子表格中

google-apps-script - Google App Script - 允许匿名用户访问

google-apps-script - 如何在ScriptDB中实现多对多关系

google-apps-script - 如何将链接附加到 Apps 脚本上的形状或文本框?

javascript - Google Apps 脚本 Web 应用程序 AJAX、jQuery、JSON?