Mahmoud Alnaanah
Mahmoud Alnaanah

Reputation: 11

In app script, how to include script.html file (without <script> tag) in index.html

I have Google app script application and the file script.html is included in index.html using the function below, and it works fine. However, script.html has a script tag, which prevents searching through function definitions, I want to include script.html in index.html without having script tag in script.html file.

The include function:

function include(filename) {
  return HtmlService.createHtmlOutputFromFile(filename).getContent();
}

Upvotes: 1

Views: 93

Answers (1)

TheWizEd
TheWizEd

Reputation: 8606

Simply put the script tabs in the html page.

HTML_Test

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <input id="test" type="button" value="Click Me" onclick="testOnClick()">
    <script>
      <?!= include("JS_Test"); ?>
    </script>
  </body>
</html>

JS_Test

function testOnClick() {
  alert("Hello");
}

Upvotes: 0

Related Questions