Open In App

HTML | sandbox Attribute

The sandbox attribute permits an additional set of restrictions for the content within the iframe. When the sandbox attribute exists, and it will:
treat the content as being from a singular origin: 
 

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.
Supported tags: 
 



Attribute Values  




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML sandbox attribute
    </title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <h2>HTML sandbox attribute</h2>
 
    <button onclick="myGeeks()">
        Click Here!
    </button>
 
    <br>
    <br>
 
    <iframe id="GFGFrame"
            src="https://ide.geeksforgeeks.org/tryit.php"
            width="400"
            height="200"
            sandbox>
    </iframe>
 
    <p id="GFG"></p>
 
 
 
 
    <!-- script to access iframe element -->
    <script>
        function myGeeks() {
            var x = document.getElementById("GFGFrame").src;
            document.getElementById("GFG").innerHTML = x;
        }
    </script>
</body>
 
</html>

Output: 
 



Supported Browsers: The browsers supported by HTML sandbox Attribute are listed below 
 

 


Article Tags :