Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
how to append html page inside current page using google web app?

I know how to include CSS or JS files using app script in a web script. but that way includes files content on page lode.

My question is it possible to include partial html page inside the currently opened page?

app script to include CSS or JS

/* @Include JavaScript & CSS & HTML-Partial-Views  */
function include(filename) {
  return HtmlService.createHtmlOutputFromFile(filename).getContent();
}

and I use like this

<?!= include('Css'); ?>

and here is my attempt.

html

<button onclick="getList("users")">show some html content</button> 
<div id="users"></div>
<script>
function getList(users){
   var listUsers = google.script.run.showHtml(users);
   // how to return showHtml result [list of users]
   for (var i; i <= listUsers.length; 1++)
   {
      document.querySelector("#users").innerHTML += <div>listUsers[i]</div>; 
   }
 }
</script>

gs

function users(sheetName, pageName){
   // get users from sheet
   var ss= SpreadsheetApp.openById("435yh35h45b35nh6hg5bwh455j");
   var dataSheet = ss.getSheetByName(sheetName);
   var dataRange = dataSheet.getDataRange().getValues();
   return dataRange;
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From one of the code snippets

// how to return showHtml result [list of users]

Try this:

<button onclick="getList('users')">show some html content</button> 
<div id="users"></div>
<script>
function getList(users){
   var listUsers = google.script.run
     .withSuccessHandler((listUsers) => {
       let list = '';
       for (var i; i < listUsers.length; i++) {
          list += `<div>${listUsers[i]}</div>\n`; 
       }
       document.querySelector("#users").innerHTML = list;
     })
     .showHtml(users);
   
 }
</script>

Changes done

  1. Replaced "users" by 'users'
  2. Added withSuccessHandler with an arrow function as callback. The arrow function build a string using a for statement (because it was used in the original code) including a div tag using a template literal.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!