自动重定向到页面 [英] Automatically Redirecting to a Page
问题描述
在按钮点击处理程序中,我创建了一个新的网页,如下所示:
Inside a button click handler, I'm creating a new web page like so:
var page = SitesApp.getPageByUrl(url).createPageFromTemplate(title, name, template);
我想将用户自动重定向到该页面。
and I want to redirect the user automatically to that page.
我无法找到很多信息,可以这样做吗?
I wasn't able to find much information, can this be done?
推荐答案
这是无法完成的在UiApp中,但它在HtmlService中是可行的:
This cannot be done in UiApp but it's doable in HtmlService:
function doGet() {
return HtmlService.createHtmlOutput(
"<form action='http://www.google.com' method='get' id='foo'></form>" +
"<script>document.getElementById('foo').submit();</script>");
}
这应该更容易;请在问题跟踪器中提交功能请求,我们会看到我们如何才能让这更愉快。
This should be easier; please file a feature request in the issue tracker and we will see how we can make this more pleasant.
(编辑:要清楚,从UiApp回调中无法做到这一点;您的整个应用程序将不得不使用HtmlService进行此操作工作。)
( To be clear, there's no way to do this from a UiApp callback; your entire app would have to be using HtmlService for this to work.)
这篇关于自动重定向到页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!