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

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

问题描述

我在 google drive 中创建了一个电子表格,并使用 google 演示文稿整理了一个教程演示文稿,向用户演示如何使用电子表格以及为什么它比我们以前使用的方式更好.

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.

我希望在打开电子表格时出现一个消息框,询问该人是否已观看教程演示文稿.如果用户单击否",我想在浏览器中打开一个新页面向他们展示我发布的演示文稿,或者在自定义 UI 中显示演示文稿.

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!

推荐答案

这样的事情做得很好.

我使用了一个假按钮来保持与另一个按钮的外观和感觉"一致,我只是在它上面添加了不可见的链接;-)

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();
}

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

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

这是它的样子:

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

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