与其他沙盒模式相比,IFRAME 模式的限制更少,运行速度也更快,但在某些旧版浏览器(包括 Internet Explorer 9)中完全不起作用。您还可以通过检查 google.script.sandbox.mode 在客户端脚本中读取沙盒模式。请注意,此属性会返回客户端上的实际模式,如果用户的浏览器不支持请求的模式,则该模式可能会与在服务器上请求的模式不同。
<!-- Read the sandbox mode (in a client-side script). -->
<script>
alert(google.script.sandbox.mode);
</script>
[[["易于理解","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"]],["最后更新时间 (UTC):2024-12-22。"],[[["SandboxMode is used for setting the sandbox environment for client-side HtmlService scripts in Google Apps Script."],["`IFRAME` is the only supported SandboxMode; `NATIVE` and `EMULATED` are deprecated and sunset."],["Client-side code in HTML service runs in a security sandbox with restrictions to protect users."],["`IFRAME` mode has fewer restrictions and runs faster but might not work in older browsers like Internet Explorer 9."],["You can read the actual sandbox mode on the client-side using `google.script.sandbox.mode`."]]],[]]