How Do You Use An External Javascript Library In A Google Apps Addon Script?
I've been working through the example code as best I can, and I've got an addon that when you click the custom menu, it pops up a dialog based on an html file (the HtmlService clas
Solution 1:
To load external javascript, you have to use scriplets in templated HTML (partially taken from GAS documentation)
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<?!= include('StylesheetFileName'); ?>
</head>
<body>
<h1>Welcome</h1>
<p>Please enjoy this helpful script.</p>
<?!= include('JavaScriptFileName'); ?>
</body>
</html>
And in your gs code you would have something like this
function showDialog() {
var html = HtmlService.createTemplateFromFile('dialog')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(400)
.setHeight(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showModalDialog(html, 'Dialog Title');
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
Post a Comment for "How Do You Use An External Javascript Library In A Google Apps Addon Script?"