Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何打开给定的Url?_Javascript_Google Apps Script_Web Applications - Fatal编程技术网

Javascript 如何打开给定的Url?

Javascript 如何打开给定的Url?,javascript,google-apps-script,web-applications,Javascript,Google Apps Script,Web Applications,我使用谷歌应用程序脚本与谷歌驱动器,我是一个非常初学者在这个问题上。现在,我想在同一个窗口中打开一个给定的Url。在标准JavaScript中,会有“open”方法: var windowObjectReference = window.open(strUrl, strWindowName[, strWindowFeatures]); HtmlService可能是使用谷歌应用程序脚本的最佳解决方案。以下代码应在同一窗口中打开Google站点: function doGet() { r

我使用谷歌应用程序脚本与谷歌驱动器,我是一个非常初学者在这个问题上。现在,我想在同一个窗口中打开一个给定的Url。在标准JavaScript中,会有“open”方法:

var windowObjectReference = window.open(strUrl, strWindowName[, strWindowFeatures]);
HtmlService可能是使用谷歌应用程序脚本的最佳解决方案。以下代码应在同一窗口中打开Google站点:

function doGet() {
     return HtmlService.createHtmlOutput(
     "<form action='http://www.google.com' method='get' id='foo'></form>" + 
     "<script>document.getElementById('foo').submit();</script>");
}
函数doGet(){
返回HtmlService.createHtmlOutput(
"" + 
“document.getElementById('foo').submit();”;
}
我打开GoogleDrive并创建了一个新脚本。我在谷歌文档脚本编辑器中输入了上述内容。但是当我从那里运行这个函数时,什么都不会发生。为什么会这样?你能纠正我吗?在新窗口中打开Google的代码是什么?

根据2012年10月26日的说明-如果没有用户交互,您将无法自动打开新窗口

打开新窗口显示HTML的最简单方法如下-

<a href='http://www.google.com' target='_blank'>Open in new window</a>