How to feature detect if iframe accepts created blob urls as src of iframe

99 Views Asked by At

When it comes to support a relatively wider range of web browsers we sometimes need some kind of defensive coding where we check if some feature is supported in a specific browser/version (e.g. IE11).

It is recommended that instead of browser sniffing it is better to employ feature detection. For example you want to use a newer web api like Shape Detection API. First you check if the API is implemented in the browser, rather than checking which browser you are runnig your app since the browsers can add/drop support in the future for a specific API, feature.

if ('BarcodeDetector' in window) {
   // do related stuff here
}

But how to detect more than the constructors or attributes etc. My specific case requires that as follows:

I need to check if my iframe accepts created Blob urls as src attribute value in iframes. According to caniuse, IE does not do that.

How can I detect that feature?

Note: As a fallback solution I think being able to throw an error on that case is also acceptable. Maybe this case described can be considered as an example of a class of browser feature detection cases and the solution in the answer can be applied to other cases of that class.

0

There are 0 best solutions below