Send feedback
HTML Service
Stay organized with collections
Save and categorize content based on your preferences.
HTML
This service allows Apps Script applications to return HTML, usually as a user interface.
If you're new to using this class, we recommend you also see the
guide to Html Service
.
Classes
Methods
Method Return type Brief description
addMetaTag(name, content)
HtmlOutput
Adds a meta tag to the page.
append(addedContent)
HtmlOutput
Appends new content to the content of this HtmlOutput
.
appendUntrusted(addedContent)
HtmlOutput
Appends new content to the content of this HtmlOutput
, using contextual escaping.
asTemplate()
HtmlTemplate
Returns an HtmlTemplate
backed by this HtmlOutput
.
clear()
HtmlOutput
Clears the current content.
getAs(contentType)
Blob
Return the data inside this object as a blob converted to the specified content type.
getBlob()
Blob
Return the data inside this object as a blob.
getContent()
String
Gets the content of this HtmlOutput
.
getFaviconUrl()
String
Gets the URL for a favicon link tag added to the page by calling setFaviconUrl(iconUrl)
.
getHeight()
Integer
Gets the initial height of the custom dialog in Google
Docs, Sheets, or Forms.
getMetaTags()
HtmlOutputMetaTag[]
Gets an array of objects that represent meta tags added to the page by calling addMetaTag(name, content)
.
getTitle()
String
Gets the title of the output page.
getWidth()
Integer
Gets the initial width of the custom dialog in Google
Docs, Sheets, or Forms.
setContent(content)
HtmlOutput
Sets the content of this HtmlOutput
.
setFaviconUrl(iconUrl)
HtmlOutput
Adds a link tag for a favicon to the page.
setHeight(height)
HtmlOutput
Sets the initial height of the custom dialog in Google
Docs, Sheets, or Forms.
setSandboxMode(mode)
HtmlOutput
This method now has no effect — previously it set the sandbox
mode
used for client-side scripts.
setTitle(title)
HtmlOutput
Sets the title of the output page.
setWidth(width)
HtmlOutput
Sets the initial width of a custom dialog in Google
Docs, Sheets, or Forms.
setXFrameOptionsMode(mode)
HtmlOutput
Sets the state of the page's X-Frame-Options
header, which controls clickjacking
prevention.
Methods
Method Return type Brief description
getContent()
String
Gets the content of this meta tag.
getName()
String
Gets the name of this HtmlOutputMetaTag
.
Properties
Property Type Description
SandboxMode
SandboxMode
An enum representing the sandbox modes that can be used for client-side HtmlService
scripts.
XFrameOptionsMode
XFrameOptionsMode
An enum representing the X-Frame-Options
modes that can be used for client-side HtmlService
scripts.
Methods
Method Return type Brief description
evaluate()
HtmlOutput
Evaluates this template and returns an HtmlOutput
object.
getCode()
String
Generates a string of JavaScript code, based on the template file, that can be evaluated.
getCodeWithComments()
String
Generates 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()
String
Returns the unprocessed content of this template.
Properties
Property Type Description
EMULATED
Enum
A legacy sandbox mode that emulates ECMAScript 5 strict mode using only the features available
in ECMAScript 3.
IFRAME
Enum
A sandbox mode that uses iframe sandboxing instead of the Caja sandbox technology used by the
EMULATED
and NATIVE
modes.
NATIVE
Enum
A sandbox mode that is built on top of ECMAScript 5 strict mode.
Properties
Property Type Description
ALLOWALL
Enum
No X-Frame-Options
header will be set.
DEFAULT
Enum
Sets the default value for the X-Frame-Options
header, which preserves normal security
assumptions.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-02-14 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2020-02-14 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-02-14 UTC."]]