Security & Privacy

sandbox="allow-same-origin"

Preserves the embedded document's normal origin rather than assigning an opaque sandbox origin. Same-origin policy still applies; combining it with allow-scripts for same-origin untrusted content can defeat sandbox isolation. A space-separated token list on iframe. An empty sandbox imposes the full sandbox restrictions; each token removes a particular restriction, not all restrictions. This inert srcdoc demonstrates syntax only, not the granted capability.

Formal Syntax & Structure

html syntaxhtml
sandbox="allow-same-origin"

Parameters & Attributes

NameTypeDescription
sandboxspace-separated token listPreserves the embedded document's normal origin rather than assigning an opaque sandbox origin. Same-origin policy still applies; combining it with allow-scripts for same-origin untrusted content can defeat sandbox isolation.

Working Example

Example Snippethtml
<iframe title="Isolated example" sandbox="allow-same-origin" srcdoc="&lt;p&gt;Embedded content&lt;/p&gt;"></iframe>

Browser Compatibility

Minimum supported versions across modern rendering engines

Chrome
5
Yes
Firefox
≤49
Yes
Safari
5
Yes
Checked desktop BCD snapshot: iframe sandbox token allow-same-origin. Versions denote the recorded start of support (≤ means at least that early), not a guarantee of all behavior. Unresolved mirror and preview rows omitted. BCD records older Chrome and Safari restrictions on script execution without allow-scripts; this token alone does not authorize scripts.
HTML Living Standard
HTML Reference