Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda