0

I've got a proper working Google Apps Script that functions perfectly on its own.

However, when I embed it into a Google Sites iframe my href to go back to the home page doesn't do anything.

<a href="<?= ScriptApp.getService().getUrl() ?>?v=home"><button type="button" class="btn btn-info">Go back</button></a>

Ive tried "base target" both "_self" and "_top" but to no avail. I've read a few things in here about setXframeOptionsMode but everything works fine except my link to go back to the home page. Here's a part of my Code.gs:

function doGet(e) {  
  Route.path('home', null, null, loadHome);
  for (var i = 0; i < 12; i++) {
    Route.path('judge', i + 1, e.parameters.pass, loadJudge);
  }
  if (Route[e.parameters.v]) {
    return Route[e.parameters.v]();
  } else {
    return render('home');
  }

}

function render(file, argsObject) {
  var tmp = HtmlService.createTemplateFromFile(file);
  if(argsObject){
    var keys = Object.keys(argsObject);
    keys.forEach(function(key){     
      tmp[key] = argsObject[key];
    });
  }
  return tmp.evaluate().setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

function loadHome(){
  return render('home');
}

Even if I could figure out how to have a button that refreshes the Google Sites page would be enough but I can't get javascript to do that either.

Can anyone help me to get this back button working in Google Sites iframe?

  • 1
    Does this answer your question? [issue with Embedding Google Apps Script in an iFrame](https://stackoverflow.com/questions/56400233/issue-with-embedding-google-apps-script-in-an-iframe) – TheMaster Aug 03 '20 at 07:28
  • it looks like it could be a possible solution, thanks for the link. i did read this one before but it looked too complicated for me to tackle. Any chance you could volunteer to teach me how to use window.postMessage() and how I can implement it? I'm not that great with coding and my code has all been written by someone else. – user1019450 Aug 03 '20 at 11:51

0 Answers0