【问题标题】:Displaying multiple hyperlinks in a msgbx/toast...?在 msgbx/toast 中显示多个超链接...?
【发布时间】:2013-07-10 03:48:39
【问题描述】:

所以基本上我有一个链接列表,我希望用户通过某种弹出窗口看到这些链接。我发现了一个类似的问题here,解决方案是制作一个 UI 面板来执行此操作。但它只适用于一个链接。我需要在同一个区域一个接一个地放置多个链接。当我为多个链接尝试此操作时,它显示一个错误,说每个父母只允许一个孩子或类似的东西。

我希望有人能把我推向正确的方向。并且实际上不可能在消息框或敬酒中放入超链接..?

提前致谢。

【问题讨论】:

  • 使用正确的面板类型,您可以添加多个链接。你可以在这里发布你的代码。也可以尝试使用不同的面板,可能是 VerticalPanel
  • 我只会发布我上面发布的链接中的代码的轻微变化。但是你和塞尔吉回答了我的问题。谢谢!

标签: hyperlink google-apps-script messagebox toast


【解决方案1】:

正如 Srik 所说,使用不同的面板,例如:

function test(){
showURL('Google','http://www.google.com','Stackoverflow','http://stackoverflow.com/questions/tagged/google-apps-script')
}

function showURL(name1,href1,name2,href2){ // for ease of use I give the urls as parameters but you could define these urls in the function as well
  var app = UiApp.createApplication().setHeight(60).setWidth(200);
  app.setTitle("Show URLs");
  var link1 = app.createAnchor(name1, href1);
  var link2 = app.createAnchor(name2, href2);

  app.add(app.createVerticalPanel().add(link1).add(link2));  // add others as needed
  var doc = SpreadsheetApp.getActive();
  doc.show(app);
  }


编辑:感谢您接受 - 如果您需要它是动态的,请尝试使用数组作为参数:

function test(){
showURL(['Google','http://www.google.com','Stackoverflow','http://stackoverflow.com/questions/tagged/google-apps-script','Google','http://www.google.com','Stackoverflow','http://stackoverflow.com/questions/tagged/google-apps-script'])
}

function showURL(data){ // for ease of use I give the urls as parameters but you could define these urls in the function as well
  var app = UiApp.createApplication().setHeight(40+8*data.length).setWidth(200);
  app.setTitle("Show URLs");
  var panel = app.createVerticalPanel();
  app.add(panel);
  for(var d=0 ; d<data.length;d=d+2){
  var link = app.createAnchor(data[d], data[(d+1)]);
  panel.add(link);
  }
  var doc = SpreadsheetApp.getActive();
  doc.show(app);
  }

【讨论】:

  • 谢谢谢尔盖!这将我推向了正确的方向。我有一个动态链接列表,但使用上面的代码并不难实现。我只需要这样的东西来运行。非常感谢!
  • 我已经开始调整您的原始代码以使用动态列表。但是你的新代码比我的要高效得多。谢谢! :)
  • 我的荣幸 :-) ,有很多方法可以让它工作......,使用数组可能是最简单的方法之一。对象也会很好......
猜你喜欢
  • 1970-01-01
  • 2013-07-14
  • 2011-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多