Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda