Auto redirect to page

Inside the button click handler, I create a new web page, for example:

var page = SitesApp.getPageByUrl(url).createPageFromTemplate(title, name, template);

and I want to automatically redirect the user to this page.

I could not find a lot of information, can this be done?

+5
source share
2 answers

This cannot be done in UiApp, but it can be done in the HtmlService:

function doGet() {
  return HtmlService.createHtmlOutput(
    "<form action='http://www.google.com' method='get' id='foo'></form>" + 
    "<script>document.getElementById('foo').submit();</script>");
}

It should be easier; please write a feature request in problem tracking and we will see how we can make it more enjoyable.

(Edit: To be clear, there is no way to do this from a UiApp callback, your entire application will need to use the HtmlService for this to work.)

+10
source

Corey G , , -, , iframe GAS, URL- - script.

, :

function doGet() {
  return HtmlService.createHtmlOutput(
    "<script>window.top.location.href='https://example.com';</script>"
  );
}

Q/A .

, .

+1

All Articles