【发布时间】:2019-06-28 11:29:41
【问题描述】:
当我单击提交时,焦点返回电子表格并加载数据,但对话框没有关闭。我使用了google.script.host.close(),但这不会将焦点传递回电子表格。
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form >
Select Client:
<div>
<select id="optionList" name="client">
</select>
</div>
Select Action:
<div>
<select id="actionList" name="action">
</select>
</div>
Username:
<input type="text" name="username"> <br />
Password:
<input type="password" name="password"> <br />
<input type="button" value="OK" onclick="google.script.run.callNumbers(this.parentNode);google.script.host.editor.focus();" />
</form>
</body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
</script>
<script>
// The code in this function runs when the page is loaded.
$(function () {
google.script.run.withSuccessHandler(buildOptionList)
.getClients();
google.script.run.withSuccessHandler(buildActionList)
.getActions();
});
function buildOptionList(clients) {
var list = $('#optionList');
list.empty();
for (var i = 0; i < clients.length; i++) {
list.append(new Option(clients[i]));
}
}
function buildActionList(actions) {
var list = $('#actionList');
list.empty();
for (var i = 0; i < actions.length; i++) {
list.append(new Option(actions[i]));
}
}
</script>
</html>
function html(){
var html = HtmlService.createHtmlOutputFromFile('load');
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.showModalDialog(html, 'Input API Creddentials');
}
我想在关闭对话框后让焦点回到电子表格。我曾尝试在沙盒模式下使用 google html 模板代替对话框,但这不起作用。
当我同时使用 google.script.host.editor.focus() 和 google.script.host.close() 时,它没有将焦点发送回工作表。
【问题讨论】:
-
When I use google.script.host.editor.focus() and google.script.host.close() together。展示你是如何一起使用它们的,以及控制台上是否有任何错误。 -
控制台上没有错误。对话框关闭。电子表格中未加载任何数据
-
先
focus(),然后再close()怎么样? -
试过了。没用
-
Dialog get closed. No data loaded on spreadsheet但是焦点在电子表格上对吗?
标签: google-apps-script web-applications