html tutorial - sandbox Attribute in HTML - html5 - html code - html form
Learn html - html tutorial - Sandbox attribute in html - html examples - html programs
- The sandbox attribute is used to enable some set of restriction for iframe contents.
- Block form submission.
- Content is treated as being from a unique origin.
- Block script execution.
- Disable APIs.
- Prevent browsing context to run scripts.
- Block plugins.
- Block automatic triggered events.
- Space separated list of values to remove the specific restriction.
Syntax for sandbox attribute in HTML:
Applies To:
Element | Attribute |
---|---|
<iframe> | sandbox |
sandbox Attribute Values:
Value | Description |
---|---|
(no value) | Applies all restrictions |
allow-forms | Re-enables form submission |
allow-pointer-lock | Re-enables APIs |
allow-popups | Re-enables popups |
allow-same-origin | Allows the iframe content to be treated as being from the same origin |
allow-scripts | Re-enables scripts |
allow-top-navigation | Allows the iframe content to navigate its top-level browsing context |
Sample Coding for sandbox Attribute in HTML:
Sample Coding for wikitechy-script.html:
Code Explanation for sandbox Attribute in HTML:
- <iframe> tag used to embed a inline frame, “wikitechy-script.html” will be embed to the current document.
- sandbox attribute is used to specify some restriction to the “wikitechy-script.html”.
Code Explanation for wikitechy-script.html:
- The script shows an alert message as “This is Wikitechy Alert”.
Output for sandbox Attribute in HTML:
- When the user hit the Click me button that does not execute the script that was blocked by the “sandbox” attribute.
- If the sandbox attribute not presents the windows shows the alert message.
Browser Support for sandbox Attribute in HTML:
4.0 | 10.0 | 17.0 | 5.0 | 15.0 |