-1

I have create simple gmail addon using google script,in that i have struggle here,

how to use onclick methond in anchor when we click anchor tage we need perform some action,i have checked the document, i couldn't find any methods The below code i have tried,

section.addWidget(CardService.newTextParagraph().setText('<a href="" onclick="notificationCallback">TestLink</a>'))

Thanks in advance

Robert
  • 3,373
  • 1
  • 18
  • 34
  • Was my answer useful for you? If you have problems for my answer yet, feel free to tell me. I would like to study to solve your problems. – Tanaike Feb 12 '18 at 22:31
  • No boss....i need more – Robert Feb 13 '18 at 04:37
  • I'm sorry for the inconvenience. Can I ask you about the problem point of my answer? I would like to think of the modification. – Tanaike Feb 13 '18 at 05:06

2 Answers2

1

It seems that <a> cannot be used for gmail add-on. A part of tags for decorating strings can be used. For example, there are <b> and <u>. So as a workaround, how about using this?

From :

section.addWidget(CardService.newTextParagraph().setText('<a href="" onclick="notificationCallback">TestLink</a>'))

To :

section.addWidget(CardService.newTextButton().setText('TestLink').setOnClickAction(notificationCallback))

If I misunderstand your question, I'm sorry.

Edit :

Since found this, added here.

basic HTML formatting: https://developers.google.com/gmail/add-ons/concepts/widgets#text_formatting.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
0

You can do simply as follows

var exampleCard = CardService.newCardBuilder();
var section=CardService.newCardSection().setHeader("Google Services");
section.addWidget(CardService.newKeyValue()
                .setContent("<a href=https://www.google.com/>google</a>"));
exampleCard.addSection(section);
return [exampleCard.build()];
Deepika
  • 1
  • 1