Open In App

HTML | DOM IFrame sandbox Property

Last Updated : 05 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The IFrame sandbox Property in HTML DOM is used for returning the value of the sandbox attribute in an iframe element. When the sandbox attribute exists, and it will:

  • treat the content as being from a singular origin
  • It blocks form submission
  • It blocks script execution
  • It disables APIs
  • It also preventing links from targeting other browsing contexts
  • It stop the content to navigate its top-level browsing context
  • block automatically triggered features (such as automatically playing a video or automatically focusing a form control)

The value of the sandbox attribute will either be simply sandboxed (then all restrictions are applied) or a space-separated list of pre-defined values which will take away the actual restrictions. Syntax: 

iframeObject.sandbox

Return Value: It returns string Value Which representing the value of the sandbox attribute. 

Now let's understand this with the help of an example:

html
<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML Iframe sandbox Attribute
        </title>
    </head>

    <body>
        <h1>GeeksforGeeks</h1>

        <h2>HTML IFrame sandbox Attribute</h2>

        <br />
        <br />

        <iframe
            id="GFGFrame"
            src="https://www.geeksforgeeks.org/community/"
            width="400"
            height="200"
            sandbox
        >
        </iframe>
    </body>
</html>


Temporary Note on Output : On Run, The iframe may show a "Refuse to Connect" error due to security restrictions from the GeeksforGeeks site, which prevents embedding. To see the output, replace the src URL with one that allows iframe embedding, such as "https://www.example.com".

Supported Browsers: The browsers supported by HTML DOM IFrame sandbox Property are listed below:

  • Google Chrome 4.0 and above
  • Edge 12.0 and above
  • Firefox 17.0 and above
  • Internet Explorer 10.0 and above
  • Opera 15.0 and above
  • Safari 5.0 and above

Next Article
Article Tags :

Similar Reads