Is there a way to add a hyperlink inside a message box of a Google Apps spreadsheet?
I have this code that displays a msgbox.
// The code below will display a message box
Browser.msgBox("Go to this site for help");
}
Is there a way to insert a hyperlink in that message box as well? Something like:
// The code below will display a message box
Browser.msgBox("Go to this site for help" & <a href="www.google.com">Help</a>);
}
This is an example of a popup showing a link to an url
function showurl() {
var app = UiApp.createApplication().setHeight('60').setWidth('150');
app.setTitle("Anchor in a popup ;-)");
var panel = app.createPopupPanel()
var link = app.createAnchor('This is your link', 'https://sites.google.com/site/appsscriptexperiments/home');
panel.add(link);
app.add(panel);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}
Google's UI service is deprecated as of Dec. 11, 2014. See here.
You should now use the HTML Service. The code to display a message with a link is below.
var htmlOutput = HtmlService
.createHtmlOutput('Go to <a href="https://www.google.ca/">this site</a> for help!')
.setWidth(250) //optional
.setHeight(50); //optional
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Help Dialog Title');
It appears Google Sheets won't run scripts for anyone who opens a public spreadsheet (obviously for security). If you want to see a live version of the dialog, just copy the above code into function onOpen() {}
in the script editor, save & refresh the spreadsheet. Otherwise, it looks like the image below.
![](https://www.manongdao.com/static/images/pcload.jpg)
If you have more HTML than a simple link, you can also create a dialog from an HTML file. In the script editor, select File > New > Html file and name it "index" (or whatever you want and change file name in code).
var html = HtmlService.createHtmlOutputFromFile('index');
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showModalDialog(html, 'Dialog title');
Sorry. Message boxes do not accept hyperlinks or tags. Plain text only.