Hide

HTML Service

HTML

This service allows scripts to return HTML, usually as a user interface. See also the guide to Html Service, as well as the guide to Ui Service, which provides an alternate way to build user interfaces.

Classes

NameBrief description
HtmlOutputAn HtmlOutput object that can be served from a script.
HtmlServiceService for returning HTML and other text content from a script.
HtmlTemplateA template object for dynamically constructing HTML.
SandboxModeAn enum representing the sandbox modes that can be used for client-side HtmlService scripts.

HtmlOutput

Methods

MethodReturn typeBrief description
append(addedContent)HtmlOutputAppends new content to the content of this HtmlOutput.
appendUntrusted(addedContent)HtmlOutputAppends new content to the content of this HtmlOutput, using contextual escaping.
asTemplate()HtmlTemplateReturns an HtmlTemplate backed by this HtmlOutput.
clear()HtmlOutputClears the current content.
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getBlob()BlobReturn the data inside this object as a blob.
getContent()StringGets the content of this HtmlOutput.
getHeight()IntegerGets the initial height of the custom dialog in Google Docs, Sheets, or Forms.
getTitle()StringGets the title of the output page.
getWidth()IntegerGets the initial width of the custom dialog or sidebar in Google Docs, Sheets, or Forms.
setContent(content)HtmlOutputSets the content of this HtmlOutput.
setHeight(height)HtmlOutputSets the initial height of the custom dialog in Google Docs, Sheets, or Forms.
setSandboxMode(mode)HtmlOutputSets the the sandbox mode used for client-side scripts.
setTitle(title)HtmlOutputSets the title of the output page.
setWidth(width)HtmlOutputSets the initial width of a custom dialog or sidebar in Google Docs, Sheets, or Forms.

HtmlService

Properties

PropertyTypeDescription
SandboxModeSandboxModeAn enum representing the sandbox modes that can be used for client-side HtmlService scripts.

Methods

MethodReturn typeBrief description
createHtmlOutput()HtmlOutputCreates a new HtmlOutput object that can be returned from the script.
createHtmlOutput(blob)HtmlOutputCreates a new HtmlOutput object from a BlobSource resource.
createHtmlOutput(html)HtmlOutputCreates a new HtmlOutput object that can be returned from the script.
createHtmlOutputFromFile(filename)HtmlOutputCreates a new HtmlOutput object from a file in the code editor.
createTemplate(blob)HtmlTemplateCreates a new HtmlTemplate object from a BlobSource resource.
createTemplate(html)HtmlTemplateCreates a new HtmlTemplate object that can be returned from the script.
createTemplateFromFile(filename)HtmlTemplateCreates a new HtmlTemplate object from a file in the code editor.

HtmlTemplate

Methods

MethodReturn typeBrief description
evaluate()HtmlOutputEvaluates this template and returns an HtmlOutput object.
getCode()StringGenerates a string of JavaScript code, based on the template file, that can be evaluated.
getCodeWithComments()StringGenerates a string of JavaScript code that can be evaluated, with each line of the code containing the original line from the template as a comment.
getRawContent()StringReturns the unprocessed content of this template.

SandboxMode

Properties

PropertyTypeDescription
EMULATEDEnumA legacy sandbox mode that emulates ECMAScript 5 strict mode using only the features available in ECMAScript 3.
IFRAMEEnumA sandbox mode that uses iframe sandboxing instead of the Caja sandbox technology used by the EMULATED and NATIVE modes.
NATIVEEnumA sandbox mode that is built on top of ECMAScript 5 strict mode.

Send feedback about...

Apps Script