【发布时间】:2019-06-02 03:58:22
【问题描述】:
我已经花了 2 天的时间试图解决这个问题,因此感谢您的帮助。
我在关注这个nice little video tutorial series 我想在进一步了解之前尝试一些基本的东西:使用 google 应用程序脚本及其 HTML 服务组件获取一个 html 按钮以显示 javascript 警报,但对于我来说,我无法理解为什么没有触发警报。
这是我的代码
索引.html
<!DOCTYPE html>
<html>
<head>
<script>
document.getElementById("btnSearch")
.addEventListener("click",showAlert);
function showAlert() {
alert("hello world");
}
</script>
</head>
<body>
<div>
<label>Enter code</label>
<input type="text" id="txtStudentID"/>
<button id="btnSearch">Search</button>
</div>
</body>
</html>
和我的 代码.gs
function doGet() {
return HtmlService.createHtmlOutputFromFile('Index');
}
我也尝试过,就像谷歌显示它here:但我仍然没有在按下按钮后触发警报:
<input type="button" value="Search"
onclick="google.script.run
.withSuccessHandler(showAlert)
.withUserObject(this)" />
就像在脚本标签中以“document.getElementByID...”开头的任何东西都不起作用
我错过了什么?这是 GAPS 不再支持的东西吗?有没有其他/正确的方法可以让它工作?
提前谢谢你。
【问题讨论】:
标签: javascript google-apps-script web-applications