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

226
Visualizações
Form Field Does Not Complete By URL In Iframe or Google Site - but does as independent web app

I am trying to complete a form created in google app script web app via URL with the intention to display the field but be inactive and a UUID for form submit.

In web app testing the form is completed by URL eg: https://script.google.com/macros/s/AKfycbwam4eZHPrs2ooVQLzJZgMcFb9gfXC2OPSq8f7Xkp9z/dev?fn=bob filling "bob" into field "fn".

However to remove googles "This application was created by another user, not by Google.Terms of Service" we put the web app in and iframe or link in google sites. This throws a spanner in the works.

Any advise will be much appreciated


    function doGet() {
      return HtmlService.createTemplateFromFile("page").evaluate().setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
    }
    
    
    function userClicked(userInfo){
     
      const url = "https://docs.google.com/spreadsheets/d/1-7D4bXhm1Yx0ekRUmrwr8fTsdQ0dLtMI4gYG-THPUdk/edit#gid=0";
      const ss = SpreadsheetApp.openByUrl(url);
      const ws = ss.getSheetByName("data");
     
     ws.appendRow([userInfo.firstName,userInfo.lastName,userInfo.app,new Date()])
    
     // Logger.log(name + " Clicked The Button");
    
    }
    
    function include(filename){
      return HtmlService.createHtmlOutputFromFile(filename).getContent();
    
    }
    <script>

        document.addEventListener('DOMContentLoaded', function() {
          var elems = document.querySelectorAll('select');
          var instances = M.FormSelect.init(elems);
        });

      document.getElementById("btn").addEventListener("click",doStuff);

      function doStuff(){

        const userInfo = {};

        userInfo.firstName = document.getElementById("fn").value;
        userInfo.lastName = document.getElementById("ln").value;
        userInfo.app = document.getElementById("app").value;

        google.script.run.userClicked(userInfo);

        document.getElementById("fn").value = "";
        document.getElementById("ln").value = "";

        var myApp = document.getElementById("app");
        myApp.selectedIndex = 0;
        M.FormSelect.init(myApp);

      }


    </script>

      <script>
        google.script.url.getLocation(function(location){

          document.getElementById('fn').value = location.parameters.fn[0]
          document.getElementById('ln').value = location.parameters.ln[0]
        })

        </script>
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Unfortunately there is no way to pass a query string parameter into a Google Apps Script web app embedded in Google Sites but this might be done by using client-side JavaScript on a "regular" web page.

Note: Use the /exec URL, not the /dev one.

<body onload="loadIframe();">
   
    <div id="content">
        <iframe width="100%" height="100%" frameborder="0"></iframe>
    </div>
    <script>
    function loadIframe(){
        const url = "put_here_your_web_app_url" + window.location.search;
        document.querySelector('iframe').src = url;
    }
    </script>
</body>

Related

  • Google Apps Script Gadget URL parameters are ignored when embedded in a Google Site
  • google site: pass parameters to embedded script
  • Google Apps script get Parent URL to iFrame in Javascript
about 4 years ago · Santiago Trujillo 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