I'm trying to build a simple web app using below code. However, when I click the button on html page, log still says no function has been run in this session. I have deployed the latest code, yet no results. I went through several links but I can't figure out what's wrong with the code.
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1> Hello</h1>
<button id="btn">Calculate</button>
<script>
document.getElementById("btn").addEventListener("click",click_handler);
function click_handler(){
google.script.run.userClicked();
}
</script>
</body>
</html>
function doGet() {
return HtmlService.createHtmlOutputFromFile("page");
}
function userClicked(){
Logger.log("Someone clicked");
}
Logger.log("Someone clicked");toreturn "Someone clicked";and fromgoogle.script.run.userClicked();togoogle.script.run.withSuccessHandler(e => alert(e)).userClicked();, when the button is clicked, an alert is opened. By this, you can check Google Apps Script works. When you modified the script, please redeploy Web Apps as new version. If this was not the direction you want, I apologize.when I updated the code to pass a parameter to the function userClicked. This is due to my poor English skill. I deeply apologize for this. In order to correctly understand about your current situation, can you provide it? If you can do, please add it to your question. By this, I would like to check it. If you can cooperate to resolve your issue, I'm glad.