[英]Pass URL from Google Script to HTML file
我在傳遞 URL 時遇到問題,我希望用戶在單擊側邊欄上的按鈕時將其傳遞給 go。
<body>
<p class="header">First we need to Authorize.</p>
<button class="center waves-effect waves-light btn" id="btn">Authorize</button>
<script>
document.getElementById("btn").addEventListener("click",authorize);
function authorize(){
google.script.run.authorizeSidebar();
}
</script>
</body>
我在 GS 上的代碼是:
function authorizeSidebar(){
var Authservice = getAuthorization();
var authorizationUrl = Authservice.getAuthorizationUrl();
//Logger.log(authorizationUrl);
}
I'm able to output the URL I need on the second function, but I'm having a hard time passing it from the GS file to the HTML file for the user to click on.
任何指導將不勝感激。
.withSuccessHandler()
中的回調 function 將收到服務器 function 返回的 url:
<script>
document.getElementById("btn").addEventListener("click",authorize);
function callbackReceiver(url){//📞☎️
alert(url);
}
function authorize(){
google.script.run
.withSuccessHandler(callbackReceiver)
.authorizeSidebar();
}
</script>
function authorizeSidebar(){
return getAuthorization()
.getAuthorizationUrl();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.