Skip to content Skip to sidebar Skip to footer

Google Web App Script Doget() Do Not Return Any Webpage After Rendering/evaluating More Than Twice

This is the link of my web app: https://script.google.com/macros/s/AKfycbzmbR9ljp7d5T8vsPTKt4b_v461NDNtxh6w6s1FFuJOhSGh6EKE/exec?view=home Step1) at home page -> OK Step

Solution 1:

I got this working without changing the sandbox. See a demo of it here: https://script.google.com/macros/s/AKfycbzeTiyAvI3qQKodHfHFXPtSP0Sy-xU6Gwpb3SoCT8GzKLCa8i5J/exec.

Code.gs

function doGet(e)
{
  if(e.parameters.view == "two")
  {
    return HtmlService.createTemplateFromFile("two").evaluate();
  }
  else if(e.parameters.view == "three")
  {
    return HtmlService.createTemplateFromFile("three").evaluate();
  }
  else if(e.parameters.view)
  {
    return HtmlService.createTemplateFromFile("error").evaluate();
  }
  else
  {
    return HtmlService.createTemplateFromFile("one").evaluate();
  }
}

one.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    one<br />
    <a href="<?= ScriptApp.getService().getUrl() ?>?view=two">two</a>
  </body>
</html>

two.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    two<br />
    <a href="<?= ScriptApp.getService().getUrl() ?>?view=three">three</a>
  </body>
</html>

three.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    three<br />
    <a href="<?= ScriptApp.getService().getUrl() ?>?view=four">four</a>
  </body>
</html>

error.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    error
  </body>
</html>

Solution 2:

You need to set base's target to the top frame. Otherwise you'll be creating a nesting frame loop because base target defaults to _self and you are loading the html in a iframe.

<base target="_top"> 

Post a Comment for "Google Web App Script Doget() Do Not Return Any Webpage After Rendering/evaluating More Than Twice"