我正在創建一個網絡應用程序,它在通過傳遞參數成功加載“searchByDocumentPage.html”之前進行了一些驗證。在我之前的代碼中,我doGet()直接使用調用該方法,ScriptApp.getService().getUrl()因此其他按鈕在加載新的 HTML 頁面時沒有任何問題。由于我做了一些驗證,出于某種原因,我無法加載“searchByDocumentPage.html”HTML 頁面。第一我試過:var html = ScriptApp.getService().getUrl()+"?v=submitDocumentID";return html;第二:return HtmlService.createTemplateFromFile("searchByDocumentPage").evaluate();if(fileID === ""){ document.getElementById("errorMessageDiv").innerHTML='<label style="color:red;text-align:center;font-style: italic;font-size: 12px;">Please key in the Document ID</label>';}else{ google.script.run.withSuccessHandler(fnFileID).getFiles(fileID);}function fnFileID(returnedVal){ if(returnedVal === "No File"){ document.getElementById("errorMessageDiv").innerHTML='<label style="color:red;text-align:center;font-style: italic;font-size: 12px;">This Document ID do not exist</label>'; } /*else{ ScriptApp.getService().getUrl()+"?v=submitDocumentID"; }*/}function getFiles(fileID) { var returnValue = ""; var arrayTblFile = []; var selectStatementTblFile = "SELECT File_ID FROM webapp_tblFile WHERE File_ID='" + fileID +"'"; arrayTblFile= MySQLSelectQuery(selectStatementTblFile);//Call the SQL }function from MySQLConnection.gs if(arrayTblFile.length == 0){ returnValue = "No File"; } else{ loadSearchByDocPage(fileID); } return returnValue;}function loadSearchByDocPage(fileID){ return HtmlService.createTemplateFromFile("searchByDocumentPage").evaluate(); //var html = ScriptApp.getService().getUrl()+"?v=submitDocumentID"; //return html;}function doGet(e){ var params = e.parameter; if(params.v === 'newDoc'){ return HtmlService.createHtmlOutputFromFile("newDocumentPage"); } else if(params.v === 'submitDocumentID'){ return HtmlService.createTemplateFromFile("searchByDocumentPage").evaluate(); } else{ return HtmlService.createTemplateFromFile("landingPage").evaluate(); }}預期通過傳遞參數加載“searchByDocumentPage.html”。
如何通過傳遞參數從 .gs 文件中的方法調用“somename.html”?
冉冉說
2021-10-29 17:17:43