I\'ve got an empty iframe and a button:
While you can set the iframe.sandbox
property as a string, it's technically a DOMTokenList interface, so you can also add()
and remove()
single tokens:
let myIframe = document.createElement('iframe');
myIframe.sandbox.add('allow-scripts');
myIframe.sandbox.toggle('allow-forms');
console.log(myIframe.sandbox.toString())
// Returns: "allow-scripts allow-forms"
console.log(myIframe.outerHTML)
// Returns: