Search code examples
google-apps-scriptgmail-addons

Google app script,gmail addon anchor with onclick method


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


Solution

  • 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.