Enum SandboxMode
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Modalità sandbox
Un'enumerazione che rappresenta le modalità sandbox che possono essere utilizzate per gli script HtmlService
lato client. È possibile accedere a questi valori da HtmlService.SandboxMode
e impostarli chiamando
HtmlOutput.setSandboxMode(mode)
.
Per chiamare un'enumerazione, chiama la relativa classe padre, il nome e la proprietà. Ad esempio,
HtmlService.SandboxMode.IFRAME
.
Le modalità NATIVE
e EMULATED
sono state
ritirate il 13 ottobre 2015 e ora non sono più disponibili. Ora è supportata solo la modalità IFRAME
.
Per proteggere gli utenti dalla pubblicazione di HTML o JavaScript dannosi, il codice lato client pubblicato dal
servizio HTML viene eseguito in una sandbox di sicurezza che impone restrizioni al codice. Il metodo
HtmlOutput.setSandboxMode(mode)
in precedenza consentiva agli autori di script di scegliere
tra diverse versioni della sandbox, ma ora non ha alcun effetto. Per ulteriori informazioni, consulta la
guida alle limitazioni nel servizio HTML.
La modalità IFRAME
impone molte meno limitazioni rispetto alle altre modalità sandbox e viene eseguita
più velocemente, ma non funziona affatto in alcuni browser meno recenti, tra cui Internet Explorer 9. La
modalità sandbox può essere letta anche in uno script lato client esaminando google.script.sandbox.mode
. Tieni presente che questa proprietà restituisce la modalità effettiva sul client, che
potrebbe differire dalla modalità richiesta sul server se la modalità richiesta non è supportata nel
browser dell'utente.
<!-- Read the sandbox mode (in a client-side script). -->
<script>
alert(google.script.sandbox.mode);
</script>
Proprietà
Proprietà | Tipo | Descrizione |
EMULATED | Enum | Una modalità sandbox legacy che emula la modalità Strict di ECMAScript 5 utilizzando solo le funzionalità disponibili
in ECMAScript 3. Questa modalità era l'impostazione predefinita prima di febbraio 2014.
EMULATED è stato ritirato a partire dal 10 dicembre
2015. Tutti gli script che tentano di utilizzare EMULATED ora utilizzeranno IFRAME .
|
IFRAME | Enum | Una modalità sandbox che utilizza la sandbox iframe anziché la tecnologia sandbox Caja utilizzata dalle modalità
EMULATED e NATIVE . Questa modalità è quella predefinita per i nuovi script a partire dal 12 novembre 2015 e per tutti gli script a partire dal 6 luglio 2016.
Questa modalità impone molte meno restrizioni rispetto alle altre modalità sandbox e viene eseguita più velocemente, ma
non funziona affatto in alcuni browser meno recenti, tra cui Internet Explorer 9.
|
NATIVE | Enum | Una modalità sandbox basata sulla modalità rigida ECMAScript 5. Una modalità sandbox basata sulla
modalità StrictMode di ECMAScript 5. Questa modalità è stata ritirata il
6 luglio 2016. Ora tutti gli script utilizzano la modalità IFRAME . |
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-08-04 UTC.
[null,null,["Ultimo aggiornamento 2025-08-04 UTC."],[[["\u003cp\u003eSandboxMode is used for setting the sandbox environment for client-side HtmlService scripts in Google Apps Script.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eIFRAME\u003c/code\u003e is the only supported SandboxMode; \u003ccode\u003eNATIVE\u003c/code\u003e and \u003ccode\u003eEMULATED\u003c/code\u003e are deprecated and sunset.\u003c/p\u003e\n"],["\u003cp\u003eClient-side code in HTML service runs in a security sandbox with restrictions to protect users.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eIFRAME\u003c/code\u003e mode has fewer restrictions and runs faster but might not work in older browsers like Internet Explorer 9.\u003c/p\u003e\n"],["\u003cp\u003eYou can read the actual sandbox mode on the client-side using \u003ccode\u003egoogle.script.sandbox.mode\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Enum SandboxMode\n\nSandboxMode\n\nAn enum representing the sandbox modes that can be used for client-side [HtmlService](/apps-script/reference/html/html-service)\nscripts. These values can be accessed from [HtmlService.SandboxMode](/apps-script/reference/html/html-service#SandboxMode), and set by calling\n[HtmlOutput.setSandboxMode(mode)](/apps-script/reference/html/html-output#setSandboxMode(SandboxMode)).\n\nTo call an enum, you call its parent class, name, and property. For example, `\nHtmlService.SandboxMode.IFRAME`.\n\nThe `NATIVE` and `EMULATED` modes were [deprecated on October 13, 2015](https://workspace.google.com/blog/product-announcements/google-apps-script-update-htmlservice) and both are now sunset. Only `IFRAME` mode is now\nsupported.\n\nTo protect users from being served malicious HTML or JavaScript, client-side code served from\nHTML service executes in a security sandbox that imposes restrictions on the code. The method\n[HtmlOutput.setSandboxMode(mode)](/apps-script/reference/html/html-output#setSandboxMode(SandboxMode)) previously allowed script authors to choose\nbetween different versions of the sandbox, but now has no effect. For more information, see the\n[guide to restrictions in HTML service](/apps-script/guides/html/restrictions).\n\nThe `IFRAME` mode imposes many fewer restrictions than the other sandbox modes and runs\nfastest, but does not work at all in certain older browsers, including Internet Explorer 9. The\nsandbox mode can also be read in a client-side script by inspecting `google.script.sandbox.mode`. Note that this property returns the actual mode on the client, which\nmay differ from the mode requested on the server if the requested mode is not supported in the\nuser's browser.\n\n```html\n\u003c!-- Read the sandbox mode (in a client-side script). --\u003e\n\u003cscript\u003e\n alert(google.script.sandbox.mode);\n\u003c/script\u003e\n``` \n\n### Properties\n\n| Property | Type | Description |\n|------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `EMULATED` | `Enum` | A legacy sandbox mode that emulates ECMAScript 5 strict mode using only the features available in ECMAScript 3. This mode was the default prior to February 2014. `EMULATED` was [sunset as of December 10, 2015](/apps-script/guides/support/sunset). All scripts attempting use `EMULATED` will now use `IFRAME` instead. |\n| `IFRAME` | `Enum` | A sandbox mode that uses iframe sandboxing instead of the Caja sandbox technology used by the `EMULATED` and `NATIVE` modes. This mode is the default for new scripts as of November 12, 2015 and for all scripts as of July 6, 2016. This mode imposes many fewer restrictions than the other sandbox modes and runs fastest, but does not work at all in certain older browsers, including Internet Explorer 9. |\n| `NATIVE` | `Enum` | A sandbox mode that is built on top of ECMAScript 5 strict mode. A sandbox mode built on top of ECMAScript 5 strict mode. This mode was [sunset as of July 6, 2016](/apps-script/guides/support/sunset). All scripts now use `IFRAME` mode. |"]]