This might be very basic, or not possible, but it's alluding me and worth asking. Is there a way to check if the html 5 progress element is supported in a browser?
var progress = document.createElement('progress');
This might be very basic, or not possible, but it's alluding me and worth asking. Is there a way to check if the html 5 progress element is supported in a browser?
var progress = document.createElement('progress');
Share
Improve this question
asked Apr 14, 2013 at 0:35
workedworked
5,8805 gold badges56 silver badges79 bronze badges
3 Answers
Reset to default 6Another oneliner, taken from Modernizr:
//returns true if progress is enabled
var supportsProgress = (document.createElement('progress').max !== undefined);
Create a progress
element and check for the max
attribute:
function progressIsSupported() {
var test = document.createElement('progress');
return (
typeof test === 'object' &&
'max' in test
);
}
Nice one liner:
function supportsProgress() {
return (t = document.createElement("progress")) && t.hasOwnProperty("max");
}
Or if you really don't want to use a global:
function supportsProgress() {
var t = document.createElement("progress");
return t && t.hasOwnProperty("max");
}