WillemS
WillemS

Reputation: 131

Show hyperlink in createhtml

In this example I try to show a simple grid with two createhtml's. The simple one (italic text) shows, but the hyperlink doesn't. How can I make the hyperlink visible?

function test() {
  var app = UiApp.createApplication().setTitle('Test html')
  var panel = app.createVerticalPanel();
  var grid = app.createGrid(4,1);
  grid.setWidget(1, 0, app.createLabel('Label'));
  grid.setWidget(2, 0, app.createHTML('<a href="http://www.google.com">Try Google</a>').setId('dir'));
  grid.setWidget(3, 0, app.createHTML('<em>This is italic text</em>'));
  panel.add(grid);
  app.add(panel);
  DocumentApp.getUi().showSidebar(app);
}

Thnx for great help!

Upvotes: 0

Views: 54

Answers (2)

Serge insas
Serge insas

Reputation: 46794

createHTML in UiApp has a limited number of authorized HTML tags :

The supported tags are listed here: https://developers.google.com/apps-script/releases/2012#march_2012

Added the ability to include a limited set of HTML tags when working with UiApp widgets, in response to this issue. Here is the list of HTML tags that are permitted: B, BLOCKQUOTE, BODY, BR, CENTER, CAPTION, CITE, CODE, DIV, EM, H1, H2, H3, H4, H5, H6, HR, I, LABEL, LEGEND, LI, OL, P, SPAN, STRONG, SUB, SUP, TABLE, TBODY, TD, THEAD, TITLE, TR, TT, UL

Use createAnchor('string text','string url') instead, see doc here

Upvotes: 0

Ido Green
Ido Green

Reputation: 2813

You will need to use:

grid.setWidget(2, 0, app.createAnchor("try", "http://www.google.com"));

It will show the link. If you wish to have an Id for that element, try to wrap it inside a span or a div.

Upvotes: 1

Related Questions