i have a simple WebApp.
I wrote script in another file ( not directly in Index.html)
I set onClick attribute to ButtonA from Index.html successfully.
and tried to set another onClick attribute to ButtonB from JavaScript.html file . But it's not working :(
What went wrong or how to achieve this..?
Below is the Code.gs file
function doGet() {
var template = HtmlService.createTemplateFromFile('Index.html') ;
var TodaysUrl = "https://google.com" ;
template.TodaysUrl = TodaysUrl;
return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME).setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent() ;
}
Below is the Index.html file
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
.button {
display : block ;
text-align : center ;
margin : 25px auto ;
padding : 10px
}
</style>
</head>
<body>
<button class="button" id="btn-a" >ButtonA Link from Index.html</button>
<button class="button" id="btn-b" >ButtonB Link from JavaScript.html</button>
<script>
document.getElementById("btn-a").onclick = function () { window.open("<?= TodaysUrl ?>" )} ;
</script>
<?!= include('JavaScript'); ?>
</body>
</html>
Below is the JavaScript.html file
<script>
document.getElementById("btn-b").onclick = function () { window.open("<?= TodaysUrl ?>" )} ;
</script>
Thanks in Advance
<?= TodaysUrl ?>into a url. That thing is not parsing JavaScript.html.