A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/apps-script/reference/html/html-service below:

Class HtmlService | Apps Script

Class HtmlService

Stay organized with collections Save and categorize content based on your preferences.

HtmlService

Service for returning HTML and other text content from a script.

Due to security considerations, scripts cannot directly return content to a browser. Instead, they must sanitize the HTML so that it cannot perform malicious actions. See the description of HtmlOutput for what limitations this implies on what can be returned.

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 Detailed documentation createHtmlOutput()

Creates a new HtmlOutput object that can be returned from the script.

const output = HtmlService.createHtmlOutput();
Return

HtmlOutput — the new HtmlOutput object

createHtmlOutput(blob)

Creates a new HtmlOutput object from a BlobSource resource.

function createFromBlob(blob) {
  const output = HtmlService.createHtmlOutput(blob);
  return output;
}
Parameters Name Type Description blob BlobSource the object to get HTML out of Return

HtmlOutput — the new HtmlOutput object

Throws

Error — if the blob doesn't contain HTML or the HTML is malformed

createHtmlOutput(html)

Creates a new HtmlOutput object that can be returned from the script.

const output = HtmlService.createHtmlOutput('<b>Hello world!</b>');
Parameters Name Type Description html String the content to serve Return

HtmlOutput — the new HtmlOutput object

Throws

Error — if the html is malformed

createHtmlOutputFromFile(filename)

Creates a new HtmlOutput object from a file in the code editor.

const output = HtmlService.createHtmlOutputFromFile('myPage');
Parameters Name Type Description filename String the name of the file to use Return

HtmlOutput — the new HtmlOutput object

Throws

Error — if the file wasn't found or the HTML in it is malformed

createTemplate(blob)

Creates a new HtmlTemplate object from a BlobSource resource.

function createFromBlob(blob) {
  const template = HtmlService.createTemplate(blob);
  const output = template.evaluate();
  return output;
}
Parameters Name Type Description blob BlobSource The object to get HTML out of. Return

HtmlTemplate — the new HtmlTemplate object

Throws

Error — if the blob doesn't contain HTML

createTemplate(html)

Creates a new HtmlTemplate object that can be returned from the script.

const template = HtmlService.createTemplate(
    '<b>The time is &lt;?= new Date() ?&gt;</b>',
);
Parameters Name Type Description html String the content of the template Return

HtmlTemplate — the new HtmlTemplate object

createTemplateFromFile(filename)

Creates a new HtmlTemplate object from a file in the code editor.

const template = HtmlService.createTemplateFromFile('myTemplate');
Parameters Name Type Description filename String the name of the file to use Return

HtmlTemplate — the new HtmlTemplate object

Throws

Error — if the file wasn't found

getUserAgent()

Gets the user-agent string for the current browser. Returns null for most script executions if not used in a web app's doGet() or doPost() function.

Return

String — the user-agent string

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 2024-12-03 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 2024-12-03 UTC."],[[["HtmlService enables scripts to safely return HTML and other text content to a browser by sanitizing the output to prevent malicious actions."],["It offers methods to create HTML output from strings, files, or blobs, and supports templates for dynamic content generation."],["HtmlService provides control over sandbox modes and `X-Frame-Options` for enhanced security."],["Developers can utilize HtmlService to build user interfaces and web applications within Google Apps Script."]]],["HtmlService allows scripts to return sanitized HTML content to browsers, preventing malicious actions. Key actions include creating `HtmlOutput` objects from strings, `BlobSource` resources, or files via `createHtmlOutput()` and `createHtmlOutputFromFile()`. Similarly, `HtmlTemplate` objects can be created using `createTemplate()` and `createTemplateFromFile()` for dynamic content. The `getUserAgent()` method retrieves the current browser's user-agent string. There are `SandboxMode` and `XFrameOptionsMode` properties that can be used for client-side `HtmlService` scripts.\n"]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4