10
09/2014
determine html5 input features
function checkInput(type) {
var input = document.createElement("input");
input.setAttribute("type", type);
return input.type == type;
}
if (checkInput("date")) {
alert("Supports date input");
}
检测 placeholder
function supports_input_placeholder() {
var i = document.createElement('input');
return 'placeholder' in i;
}
if (Modernizr.input.placeholder) {
// your placeholder text should already be visible!
} else {
// no placeholder support :(
// fall back to a scripted solution
}
检测 video
普通的 tag 没有这个属性。
function supports_video() {
return !!document.createElement('video').canPlayType;
}