To enable these restrictions, specify the sandbox attribute, as shown in the following code example.
When iframe elements are sandboxed, the following actions are restricted:
- Sandboxed content cannot open pop-up windows or new browser windows. Methods that open pop-up windows (such as createPopup(), showModalDialog(), showModelessDialog(), and window.open()), fail silently.
- Links cannot be opened in new windows.
- Sandboxed content is considered to be from a unique domain, which prevents access to APIs that are protected by the same-origin policy such as cookies, local storage, and the Document Object Model (DOM) of other documents.
- The top window cannot be navigated by sandboxed content.
- Sandboxed content cannot submit form data.
- Plugins (object, applet, embed, or frame) do not instantiate.
- Automatic element behavior is disabled, including meta element refresh, autofocus for input controls, and autoplay for audio and video elements.
- Selected features proprietary to Windows Internet Explorer are disabled for sandboxed content, including HTML Components (HTCs), binary behaviors, databinding, and window.external.
Sandboxed content can submit forms.
Sandboxed content can access APIs protected by the same-origin policy, including local storage, cookies, XMLHttpRequest, and documents hosted on the same domain.
Sandboxed content is allowed to change the location of the top window.
Sandboxed content is allowed to open popup windows.
Note Pre-release versions of Internet Explorer 10 supported this value using a vendor prefix. Applications that use a vendor-prefix for this value should be updated to ensure future compatibility and standards-compliance.
The following example shows a sandboxed iframe element that uses customization flags to customize the restrictions for the content in the element.
This example permits form submission and access to local data sources. Be aware that multiple customization flags are separated by spaces.
- HTML5: Sections 4.8.2, 5.4
Build date: 11/17/2013