لاستدعاء تعداد، عليك استدعاء الفئة الرئيسية والاسم والخاصية. مثلاً:
HtmlService.SandboxMode.IFRAME
تم
إيقاف الوضعَين NATIVE وEMULATED نهائيًا في 13 أكتوبر 2015. يتوفّر الآن وضع IFRAME فقط.
لحماية المستخدمين من عرض محتوى HTML أو JavaScript ضار، يتم تنفيذ الرمز البرمجي من جهة العميل الذي يتم عرضه من خدمة HTML في بيئة اختبار آمنة تفرض قيودًا على الرمز البرمجي. كانت الطريقة HtmlOutput.setSandboxMode(mode) تسمح سابقًا لمؤلفي البرامج النصية بالاختيار بين إصدارات مختلفة من البيئة التجريبية، ولكنها لم تعُد تؤثر في ذلك. لمزيد من المعلومات، يُرجى الاطّلاع على دليل القيود في خدمة HTML.
يفرض الوضع IFRAME قيودًا أقل بكثير من أوضاع وضع الحماية الأخرى، ويعمل بأسرع ما يمكن، ولكنّه لا يعمل على الإطلاق في بعض المتصفّحات القديمة، بما في ذلك Internet Explorer 9. يمكن أيضًا قراءة وضع الحماية في نص برمجي من جهة العميل من خلال فحص 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.
تاريخ التعديل الأخير: 2025-08-04 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-04 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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. |"]]