sandbox

object sandbox extends Attr

If specified as an empty string, this attribute enables extra restrictions on the content that can appear in the inline frame. The value of the attribute can either be an empty string (all the restrictions are applied), or a space-separated list of tokens that lift particular restrictions. Valid tokens are:

  • <code>allow-forms</code>: Allows the embedded browsing context to submit forms. If this keyword is not used, this operation is not allowed.
  • <code>allow-modals</code>: Allows the embedded browsing context to open modal windows.
  • <code>allow-orientation-lock</code>: Allows the embedded browsing context to disable the ability to lock the screen orientation.
  • <code>allow-pointer-lock</code>: Allows the embedded browsing context to use the <a href="/en-US/docs/WebAPI/Pointer_Lock">Pointer Lock API</a>.
  • <code>allow-popups</code>: Allows popups (like from <code>window.open</code>, <code>target="_blank"</code>, <code>showModalDialog</code>). If this keyword is not used, that functionality will silently fail.
  • <code>allow-popups-to-escape-sandbox</code>:  Allows a sandboxed document to open new windows without forcing the sandboxing flags upon them. This will allow, for example, a third-party advertisement to be safely sandboxed without forcing the same restrictions upon a landing page.
  • <code>allow-presentation</code>: Allows embedders to have control over whether an iframe can start a presentation session.
  • <code>allow-same-origin</code>: Allows the content to be treated as being from its normal origin. If this keyword is not used, the embedded content is treated as being from a unique origin.
  • <code>allow-scripts</code>: Allows the embedded browsing context to run scripts (but not create pop-up windows). If this keyword is not used, this operation is not allowed.
  • <code>allow-top-navigation</code>: Allows the embedded browsing context to navigate (load) content to the top-level browsing context. If this keyword is not used, this operation is not allowed.
  • <code>allow-top-navigation-by-user-activation</code>: Allows the embedded browsing context to navigate (load) content to the top-level browsing context only when initiated by a user gesture. If this keyword is not used, this operation is not allowed.

<strong>Note:</strong>

  • When the embedded document has the same origin as the main page, it is strongly discouraged to use both <code>allow-scripts</code> and <code>allow-same-origin</code> at the same time, as that allows the embedded document to programmatically remove the <code>sandbox</code> attribute. Although it is accepted, this case is no more secure than not using the <code>sandbox</code> attribute.
  • Sandboxing in general is only of minimal help if the attacker can arrange for the potentially hostile content to be displayed in the user's browser outside a sandboxed <code>iframe</code>. It is recommended that such content should be served from a <em>separate dedicated domain</em>, to limit the potential damage.
  • The <code>sandbox</code> attribute is not supported in Internet Explorer 9 and earlier versions.
trait Attr
class Object
trait Matchable
class Any

Type members

Classlikes

object tag extends TagElement

Types

Inherited types

type supports[T <: Tag] = AttrPair[attrType] => AttrPair[tagType]
Inherited from
Attr

Value members

Concrete methods

@inline
def :=(v: String): AttrPair[_sandbox_attr]
@inline
def :=(v: Option[String]): OptionalAttrPair[_sandbox_attr]