[英]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.