Enum SandboxMode
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
सैंडबॉक्समोड
यह एक इनम है. यह उन सैंडबॉक्स मोड को दिखाता है जिनका इस्तेमाल क्लाइंट-साइड HtmlService
स्क्रिप्ट के लिए किया जा सकता है. इन वैल्यू को HtmlService.SandboxMode
से ऐक्सेस किया जा सकता है. साथ ही, इन्हें HtmlOutput.setSandboxMode(mode)
को कॉल करके सेट किया जा सकता है.
किसी enum को कॉल करने के लिए, उसकी पैरंट क्लास, नाम, और प्रॉपर्टी को कॉल करें. उदाहरण के लिए,
HtmlService.SandboxMode.IFRAME
.
NATIVE
और EMULATED
मोड को
13 अक्टूबर, 2015 को बंद कर दिया गया था. अब ये दोनों मोड उपलब्ध नहीं हैं. अब सिर्फ़ IFRAME
मोड काम करता है.
उपयोगकर्ताओं को नुकसान पहुंचाने वाले एचटीएमएल या JavaScript से बचाने के लिए, एचटीएमएल सेवा से दिखाया गया क्लाइंट-साइड कोड, सुरक्षा सैंडबॉक्स में काम करता है. यह कोड पर पाबंदियां लगाता है. इस तरीके से, स्क्रिप्ट लिखने वाले लोग HtmlOutput.setSandboxMode(mode)
पहले सैंडबॉक्स के अलग-अलग वर्शन में से किसी एक को चुन सकते थे. हालांकि, अब इसका कोई असर नहीं होता. ज़्यादा जानकारी के लिए, एचटीएमएल सेवा से जुड़ी पाबंदियों के बारे में गाइड देखें.
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 | यह सैंडबॉक्स मोड है. इसमें EMULATED और NATIVE मोड में इस्तेमाल की जाने वाली Caja सैंडबॉक्स टेक्नोलॉजी के बजाय, iframe सैंडबॉक्सिंग का इस्तेमाल किया जाता है. यह मोड, 12 नवंबर, 2015 से नई स्क्रिप्ट के लिए डिफ़ॉल्ट रूप से उपलब्ध है. साथ ही, 6 जुलाई, 2016 से सभी स्क्रिप्ट के लिए डिफ़ॉल्ट रूप से उपलब्ध है.
इस मोड में, अन्य सैंडबॉक्स मोड की तुलना में बहुत कम पाबंदियां होती हैं. साथ ही, यह सबसे तेज़ी से काम करता है. हालांकि, यह Internet Explorer 9 जैसे कुछ पुराने ब्राउज़र में काम नहीं करता.
|
NATIVE | Enum | यह सैंडबॉक्स मोड, ECMAScript 5 के स्ट्रिक्ट मोड पर आधारित है. यह सैंडबॉक्स मोड, ECMAScript 5 के स्ट्रिक्ट मोड पर आधारित है. इस मोड को 6 जुलाई, 2016 से बंद कर दिया गया है. सभी स्क्रिप्ट अब IFRAME मोड का इस्तेमाल करती हैं. |
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 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. |"]]