sandbox

The sandbox attribute enables an extra set of restrictions for the content in the iframe. When the sandbox attribute is present, and it will: treat the content as being from a unique origin. block form submission. block script execution.

sometime we get error while submitting form also get error regarding javascript we get this error because iframe by default apply restriction for iframe to avoid this kind of error we use sandbox attribute to remove restriction

sandbox provide different values for restrictions example:

allow-forms Allows form submission

allow-same-origin Allows the iframe content to be treated as being from the same origin

allow-script Allows to run scripts

syntex:

<iframe sandbox=" "></iframe>

description:

here sandbox empty value means its allow all restrictions in iframe ex:- its restrict form submission its give error while submitting form

for remove this restriction we send particular value to remove restriction example:-

in above example we remove form submission restriction by using pass allow-form value we can remove different like this by providing separate value in sandbox

examples:

<iframe src="https://xyz.com" width="100px" height="100px" sandbox="allow-forms"></iframe>

Last updated