これは非常に基本的であるか、不可能である可能性がありますが、それは私をほのめかしており、尋ねる価値があります. HTML 5 の進行状況要素がブラウザーでサポートされているかどうかを確認する方法はありますか?
var progress = document.createElement('progress');
これは非常に基本的であるか、不可能である可能性がありますが、それは私をほのめかしており、尋ねる価値があります. HTML 5 の進行状況要素がブラウザーでサポートされているかどうかを確認する方法はありますか?
var progress = document.createElement('progress');
Modernizrから取得した別のワンライナー:
//returns true if progress is enabled
var supportsProgress = (document.createElement('progress').max !== undefined);
progress
要素を作成し、max
属性を確認します。
function progressIsSupported() {
var test = document.createElement('progress');
return (
typeof test === 'object' &&
'max' in test
);
}
ナイスワンライナー:
function supportsProgress() {
return (t = document.createElement("progress")) && t.hasOwnProperty("max");
}
または、本当にグローバルを使用したくない場合:
function supportsProgress() {
var t = document.createElement("progress");
return t && t.hasOwnProperty("max");
}