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

223
Vistas
Javascript Limitations of Google Apps Scripts WebApps?

C'mon help me push the boundaries a little here...

Google supports sticking your Javascript in an html file. This guy shows how to display images in a webapp done in a google script. That guy makes those images have s3x (I mean, give me a better description here!)

Settings variables for the images residing in a Google Drive in the Code.gs and later trying to use them in the javascript file doesn't work. I get a blank screen.

Is this a limitation of Google or a Javascript knowledge limitation on my part?

This here is the code dot js where I map the two images.

Code.gs

This shows the html we see

Page.html

This is where the magic happen...

Javascript.html

the css....

the css

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Issue:

You instantiated pic1 and pic2 in your Code.gs and is expecting to have those values when you are in your HTML/JavaScript file which is not totally the case.

Solution:

To pass values from server side to client side, use google.script.run. You can directly call get_the_images instead of instantiating it to variables then passing them. See sample code below on how values are passed from GS to your HTML/JavaScript.

Code.gs:

function doGet() {
  var htmlOutput = HtmlService.createTemplateFromFile('Page');
  return htmlOutput.evaluate();
}

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

function get_the_images() {
  // supposedly ID of said images (IDs for test purposes)
  return ['rxcmaiw_23jsu', 'qwejiasd23saf'];
}

Page.html:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    value of pic1 id is:
    <span id="pic1">
    </span>
    </br>
    value of pic2 id is:
    <span id="pic2">
    </span>

    <?!= include('Javascript'); ?>
  </body>
</html>

Javascript.html:

<script>
  let span1 = document.querySelector('#pic1');
  let span2 = document.querySelector('#pic2');
  // call get_the_images function from Code.gs
  google.script.run.withSuccessHandler(onSuccess).get_the_images();

  function onSuccess(result){
    // result contains the return value of get_the_images
    var [pic1, pic2] = result;
    // at this point, pic1 and pic2 contains the ids
    // show them as images using your script
    // below just confirms the IDs if passed properly
    span1.innerHTML = pic1;
    span2.innerHTML = pic2;
  }
</script>

Output:

output

Reference:

  • https://developers.google.com/apps-script/guides/html/reference/run
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