Skip to content

Instantly share code, notes, and snippets.

@mytharcher
Created March 3, 2012 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mytharcher/1966957 to your computer and use it in GitHub Desktop.
Save mytharcher/1966957 to your computer and use it in GitHub Desktop.
JS检测HTML5的标签兼容性
/*
* jslib JavaScript Library
*
* create:
* @2011-07-28 by mytharcher
*
* update:
*/
///import js.client.Features;
/**
* 是否支持html5中新的标签
* (枚举对象)
* @property js.client.Features.Tags
* @type {Object}
*/
js.client.Features.Tags = (function (tagSource) {
var ret = {},
tags = tagSource.split(' ')
testDiv = document.createElement('div');
for (var i = tags.length - 1; i >= 0; i--) {
var tag = tags[i];
testDiv.innerHTML = '<' + tag + '></' + tag + '>';
ret[tag] = testDiv.firstChild.nodeType == 1;
}
testDiv = null;
return ret;
})('article aside audio canvas command datalist details dialog embed'
+ ' figcaption figure footer header hgroup keygen mark meter nav'
+ ' output progress rp rt section time video');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment