如何打开给定的Url? [英] How to open a given Url?

查看:107
本文介绍了如何打开给定的Url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google云端硬盘中使用Google Apps脚本,在这件事上我是一个非常初学者。现在,我想在同一个窗口中打开给定的Url。在标准的Java脚本中,会有'open'方法:
$ b $ $ $ $ p $ var $ window $ strWindowFeatures]);

可能HtmlService是Google Apps脚本的最佳解决方案。下面的代码应该在同一个窗口中打开Goog​​le站点:

 函数doGet(){
返回HtmlService。 createHtmlOutput(
< form action ='http://www.google.com'method ='get'id ='foo'>< / form>+
< script> ;的document.getElementById( '富')提交();< /脚本>中);
}

我打开Goog​​le云端硬盘并创建了一个新脚本。我在Google Docs Script的编辑器中输入了上述内容。但是当我从那里运行这个功能时,什么都不会发生。为什么这样?你能纠正我吗?那么在新窗口中打开Goog​​le的代码是什么? 根据版本 2012年10月26日的备注 - 您无法再自动打开新窗口,无需用户互动



最简单的方式打开一个新窗口来显示这样的HTML -

 < a href ='http://www.google.com'target ='_ blank'>在新窗口中打开< / a> 


I am using Google Apps Script with Google Drive, and I am a very beginner in this matter. Now, I would like to open a given Url in the same window. In standard Java Script, there would be the 'open' method:

var windowObjectReference = window.open(strUrl, strWindowName[, strWindowFeatures]);

Probably, HtmlService would be the best solution with Google Apps Script. The following code should open the Google-site in the same window:

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

I opened Google Drive and created a new script. I typed in the above content in the editor of Google Docs Script. But when I am running this function from there, nothing at all will happen. Why so? Could you correct me? And what would be the code for opening Google in a new window?

解决方案

Per the Release Notes for Oct 26, 2012 - you can no longer auto open a new window without user interaction.

The simplest way to open a new window to show an HTML like this -

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

这篇关于如何打开给定的Url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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