Enum SandboxMode
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מצב Sandbox
סוג enum שמייצג את מצבי ארגז החול שאפשר להשתמש בהם בסקריפטים HtmlService
מצד הלקוח. אפשר לגשת לערכים האלה מ-HtmlService.SandboxMode
ולהגדיר אותם באמצעות הקריאה ל-HtmlOutput.setSandboxMode(mode)
.
כדי לקרוא ל-enum, קוראים למחלקת האב, לשם ולמאפיין שלו. לדוגמה,
HtmlService.SandboxMode.IFRAME
.
הוצאנו משימוש את המצבים NATIVE
ו-EMULATED
ב-
13 באוקטובר 2015, ועכשיו הם כבר לא זמינים. עכשיו יש תמיכה רק במצב IFRAME
.
כדי להגן על המשתמשים מפני קוד HTML או JavaScript זדוניים שמוצגים להם, קוד בצד הלקוח שמוצג משירות HTML מופעל בארגז חול מאובטח שמטיל הגבלות על הקוד. השיטה HtmlOutput.setSandboxMode(mode)
אפשרה בעבר לכותבי סקריפטים לבחור בין גרסאות שונות של ארגז החול, אבל עכשיו אין לה השפעה. מידע נוסף זמין במדריך בנושא הגבלות בשירות HTML.
מצב IFRAME
מטיל הרבה פחות הגבלות מאשר מצבי ארגז החול האחרים, והוא פועל הכי מהר, אבל הוא לא פועל בכלל בדפדפנים ישנים מסוימים, כולל Internet Explorer 9. אפשר גם לקרוא את מצב הארגז ב-script בצד הלקוח על ידי בדיקה של google.script.sandbox.mode
. שימו לב שהמאפיין הזה מחזיר את המצב בפועל בלקוח, שיכול להיות שונה מהמצב שנדרש בשרת אם המצב שנדרש לא נתמך בדפדפן של המשתמש.
<!-- Read the sandbox mode (in a client-side script). -->
<script>
alert(google.script.sandbox.mode);
</script>
מאפיינים
נכס | סוג | תיאור |
EMULATED | Enum | מצב ארגז חול מדור קודם שמדמה מצב מחמיר של ECMAScript 5 באמצעות התכונות שזמינות ב-ECMAScript 3 בלבד. המצב הזה היה ברירת המחדל לפני פברואר 2014.
EMULATED יצא משימוש ב-10 בדצמבר 2015. כל הסקריפטים שמנסים להשתמש ב-EMULATED ישתמשו עכשיו ב-IFRAME במקום זאת.
|
IFRAME | Enum | מצב ארגז חול שמשתמש בארגז חול של iframe במקום בטכנולוגיית ארגז החול של Caja שמשמשת במצבים EMULATED ו-NATIVE . החל מ-12 בנובמבר 2015, המצב הזה הוא ברירת המחדל לתסריטים חדשים, והחל מ-6 ביולי 2016 הוא ברירת המחדל לכל התסריטים.
במצב הזה יש הרבה פחות הגבלות מאשר במצבי ארגז חול אחרים, והוא פועל הכי מהר, אבל הוא לא פועל בכלל בדפדפנים ישנים מסוימים, כולל Internet Explorer 9.
|
NATIVE | Enum | מצב ארגז חול שמבוסס על מצב קפדני של ECMAScript 5. מצב ארגז חול שמבוסס על מצב קפדני של ECMAScript 5. המצב הזה יצא משימוש ב-6 ביולי 2016. כל הסקריפטים משתמשים עכשיו במצב IFRAME . |
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-04 (שעון UTC).
[null,null,["עדכון אחרון: 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. |"]]