如何使用谷歌应用程序脚本打开Web浏览器? [英] How do I open a web browser using google apps script?

查看:184
本文介绍了如何使用谷歌应用程序脚本打开Web浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在谷歌驱动器中创建了一个电子表格,并且我已经使用Google演示文稿制作了一个教程演示文稿,以向用户演示如何使用电子表格以及为什么它比我们之前做的更好。

我想要的是当电子表格打开时显示一个消息框,询问该人是否已经观看了教程演示文稿。如果用户点击否,我想要在浏览器中打开一个新页面,向他们展示我发布的演示文稿,或者在自定义用户界面中显示演示文稿。



我搜索了几个小时,却找不到它。这可能吗?感谢您的帮助!



我是新来的论坛,所以请让我知道,如果我发布这个错误。谢谢!

解决方案

类似这样的功能很好。



我使用了一个假按钮来保持与其他按钮一致的外观和感觉,我只是将链接隐藏在其上; - )

 函数alertLink(){
var doc = SpreadsheetApp.getActiveSpreadsheet();
var app = UiApp.createApplication()。setTitle('Message')。setHeight('100')。setWidth('400');
var panel = app.createVerticalPanel()。add(app.createHTML('您看到我美丽的< b>教程< / b>?));
var grid = app.createGrid(1,2).setWidth('400');
var closeHandler = app.createServerHandler('close');
var b1 = app.createButton(NO and I'd like to)。setTitle('在新标签页中进入教程');
var b2 = app.createButton(YES,我不想再看到它,closeHandler).setTitle('关闭此窗口');
var link = app.createAnchor('XXXXXXXXXX','http://www.google.com').setStyleAttributes({'zIndex':'1','position':'fixed','top' :'25','left':'20','color':'transparent'})。setTitle('转到新标签中的教程');
var G1 = app.createVerticalPanel()。add(b1).add(link);
grid.setWidget(0,0,G1).setWidget(0,1,b2);
app.add(panel).add(grid)
doc.show(app)
}

function close(){
return UiApp。 getActiveApplication()close()方法。

$ / code>

只需使用 onOpen 如果您希望在电子表格打开时自动执行,则触发。 (或将主函数重命名为 onOpen()



以下是它的样子:




I've created a spreadsheet in google drive, and I've put together a tutorial presentation using google presentations to demonstrate to the users how to use the spreadsheet and why it's better than the way we were doing it before.

What I would like is a message box to appear when the spreadsheet is opened asking if that person has watched the tutorial presentation yet. If the user clicks No I'd like to either open a new page in the browser to show them the presentation I've published, or show the presentation in a custom UI.

I've searched for hours and can't figure it out. Is this possible? Thank you for your help!

I'm new to the forum so please let me know if I posted this wrong. Thanks!

解决方案

Something like this does it pretty well.

I used a fake button to keep the "look and feel" consistent with the other button , I simply added the link invisible on top of it ;-)

function alertLink() {
  var doc = SpreadsheetApp.getActiveSpreadsheet();
  var app = UiApp.createApplication().setTitle('Message').setHeight('100').setWidth('400');
  var panel = app.createVerticalPanel().add(app.createHTML('Did you see my beautiful <b>Tutorial</b> ?'));
  var grid = app.createGrid(1,2).setWidth('400');
  var closeHandler = app.createServerHandler('close');
  var b1 = app.createButton("NO and I'd like to").setTitle('go to the tutorial in a new tab');
  var b2 = app.createButton("YES and I don't want to see it again",closeHandler).setTitle('close this window');
  var link = app.createAnchor('XXXXXXXXXX','http://www.google.com').setStyleAttributes({'zIndex':'1' , 'position':'fixed' , 'top':'25' , 'left':'20', 'color':'transparent' }).setTitle('go to the tutorial in a new tab');
  var G1 = app.createVerticalPanel().add(b1).add(link);
  grid.setWidget(0,0,G1).setWidget(0,1,b2);
  app.add(panel).add(grid)
  doc.show(app)
}

function close(){
  return UiApp.getActiveApplication().close();
}

Just use an onOpen trigger if you want it to execute automatically on spreadsheet open. (or rename the main function as onOpen() )

Here is how it looks like :

这篇关于如何使用谷歌应用程序脚本打开Web浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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