Gonzalo Hernandez
Gonzalo Hernandez

Reputation: 737

How to redirect to another webpage from Google Apps Script Gadget?

I'm building a web application in Google Sites. Currently, I have two forms, the first one loads a Spreadsheet and displays it as a table, then when you select a row from the table, the script calls another Web App with a GET request and with a few parameters (as ?rowIndex=X&columnIndex=..).

This is working fine if I deploy the first form as a Web App. But if I insert the first script as a "Google Apps Script Gadget" in my Google Sites webpage it seems that is embedded as an Iframe that cannot redirect to other webpages/scripts (it just shows a blank iframe).

Is there any way to solve this without merging both scripts in one?

For the redirect, I'm using javascript in the HTML form.

windows.location="secondScriptUrl"+"?parameters..." 

and the second script just generates the HTML from the doGet function

function doGet(e) {
   return HtmlService.createTemplateFromFile('index').evaluate();
}

Upvotes: 2

Views: 7559

Answers (1)

Gonzalo Hernandez
Gonzalo Hernandez

Reputation: 737

I solved it adding:

<base target="_top">

to the html code and changing the javascript redirect:

window.top.location.href = url; 

Upvotes: 2

Related Questions