1
我已經編寫了此腳本來搜索特定用戶擁有的文件的驅動器 - 除此功能外,它的工作效果很好,返回所有結果並且鏈接設置爲像doc一樣打開。所以pdf和其他文件我得到一個錯誤,因爲URL是錯誤的。有沒有通用的方法來打開文件,或者我需要寫if語句?任何可能的想法如何解決這個問題?感謝網頁應用鏈接查看驅動器內的任何文件
function handleResults(results){
console.log('Handle Results was called! ');
document.writeln('<a href="https://script.google.com/a/macros/35634534534534534534534534534">BACK</a><br/><br/>');
var length=results.length; // total elements of results
for(var i=0;i<length;i++)
{
var item=results[i];
item=item.split("|~|"); // split the line |~|, position 0 has the filename and 1 the file id
document.writeln("<b><a href='https://docs.google.com/document/d/"+item[1]+"' target='_blank'>"+item[0]+"</b></a> (Last modified: "+item[2]+")<br/><br/>"); // write result
}
document.writeln("End of results...");
}
你嘗試'File.getUrl()'? API的文檔是[here](https://developers.google.com/apps-script/reference/drive/file) – SpiderPig