如何从Google Apps脚本小工具重定向到另一个网页? [英] How to redirect to another webpage from Google Apps Script Gadget?

查看:110
本文介绍了如何从Google Apps脚本小工具重定向到另一个网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Google协作平台中构建一个Web应用程序.目前,我有两种形式,第一种形式是加载电子表格并将其显示为表格,然后当您从表格中选择一行时,脚本会使用GET请求和一些参数(如?rowIndex=X&columnIndex=.. ).

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=..).

如果我将第一个表单部署为Web App,这将很好地工作.但是,如果我将第一个脚本作为"Google Apps脚本小工具"插入,在我的Google协作平台网页中,它似乎是作为iframe嵌入的,无法重定向到其他网页/脚本(仅显示空白的iframe).

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?

对于重定向,我使用HTML表单中的javascript.

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

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

,第二个脚本只是通过doGet函数生成HTML

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

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

推荐答案

我添加了解决方案:

<base target="_top">

更改为html代码并更改javascript重定向:

to the html code and changing the javascript redirect:

window.top.location.href = url; 

这篇关于如何从Google Apps脚本小工具重定向到另一个网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆