HTML | DOM IFrame sandbox Property

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.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML DOM iframe sandbox Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1>GeeksforGeeks</h1>
  
    <h2
        HTML DOM iframe sandbox Property 
    </h2>
  
            id="GFG" 
            height="200"
            width="400" 
            sandbox="allow-scripts">
    </iframe>
  
    <br>
    <br>
  
    <button onclick="Geeks()">
        Submit
    </button>
    <p id="sudo"></p>
    <script>
        function Geeks() {
            var iframeID = document.getElementById("GFG").sandbox;
            document.getElementById("sudo").innerHTML = iframeID;
        }
    </script>
</body>
  
</html>

chevron_right


    Output:

  • Before Clicking on Button:
  • After Clicking on Button:

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

  • Google Chrome 4.0
  • Internet Explorer 10.0
  • Firefox 17.0
  • Apple Safari 5.0
  • Opera 15.0


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh

Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.