Search code examples
google-apps-scriptweb-applications

Message Box with link


I am trying to popup a message box in a Google Sheet with a text and clickable hyperlink.

My searches so far yielded deprecated ui-functions.


Solution

  • function msgBoxWithLink(msg,link,desc) {
      var link=link || 'http://jimesteban.com';
      var desc=desc || 'Description';
      var msg=msg || 'Link';
      var html=Utilities.formatString('<style>input{margin: 5px 0;}</style><h3>%s</h3><a href="%s" target="_blank">%s</a><br /><input type="button" value="Close" onClick="google.script.host.close();" />',msg,link,desc);
      var userInterface=HtmlService.createHtmlOutput(html);
      SpreadsheetApp.getUi().showModelessDialog(userInterface, "Message Box with Link");
    }