Detect support for HTML5 iframe sandbox attribute
You can check whether an iframe
element has the sandbox
attribute:
var sandboxSupported = "sandbox" in document.createElement("iframe");
Side note
A good way to find feature detects is to look at Modernizr and see if it has one already. This is the Modernizr code for the sandbox attribute test:
Modernizr.addTest('sandbox', 'sandbox' in document.createElement('iframe'));
Alternatively (if you need to use lots of feature detects in your app) include Modernizr and use it properly, instead of just getting ideas from its source!