簡體   English   中英

Google Apps腳本,用於以超鏈接形式返回文本

[英]Google Apps Script, function to return text as hyperlink

我有一個Google Apps腳本函數SearchFiles() ,該函數根據用戶提供的關鍵字返回下載網址。 它是這樣的:

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信息嵌入到字符串中(例如<a href=downloadUrl>...</a>" )。這可以在客戶端解釋為鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM