Detect support for HTML5 iframe sandbox attribute Detect support for HTML5 iframe sandbox attribute google-chrome google-chrome

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!


The fastest way to check the new HTML5 features supported by your browser, check this link HTML5Test and for CSS3 features check this link CSS3Test.The cool thing is that you can compare the shown result to other browsers at the same page.