【问题标题】:Google Apps Script, function to return text as hyperlinkGoogle Apps 脚本,以超链接形式返回文本的函数
【发布时间】:2016-02-10 19:19:03
【问题描述】:

我有一个 Google Apps 脚本函数 SearchFiles(),它根据用户提供的关键字返回下载 url。是这样的:

function SearchFiles(inputValueFromUser) {


  var searchFor ='title contains "' + inputValueFromUser + '"';
  var searchForAbsString = inputValueFromUser + '.pdf' ;

  //The Rest of the Code goes here

    if(file.getName() == searchForAbsString){
    downloadURL = "https://drive.google.com/uc?export=download&id=" + fileId;
    arryOfUrls.push(downloadURL);
    };
  };

  Logger.log('arryOfUrls: ' + arryOfUrls);
  return arryOfUrls;//.toString(); //Send array of download urls back to client side JavaScript 
};

函数以纯文本形式返回arryOfUrls

1) 如何以超链接形式发送? 2) 是否可以通过单击相应按钮(Index.html)自动打开 URL(立即开始下载)以获取链接?

【问题讨论】:

  • 不,它不能直接作为超链接发送(至少据我所知)。但是您可以将 HTML 信息嵌入到字符串中(如“")。这可以在客户端解释为一个链接。
  • 我之前也是这么想的,但不敢尝试。非常感谢……它奏效了。请将其作为答案发布,以便我将其标记为正确。

标签: javascript google-apps-script


【解决方案1】:

不,它不能直接作为超链接发送(至少据我所知不是)。但是您可以将 HTML 信息嵌入到字符串中(如<a href=downloadUrl>...</a>")。这可以在客户端解释为一个链接。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    相关资源
    最近更新 更多