Ответ 1
Недопустимые значения будут отклонены при назначении атрибуту .type
элемента input
.
try {
var input = document.createElement("input");
input.type = "time";
if (input.type === "time") {
console.log("supported");
} else {
console.log("not supported");
}
} catch(e) {
console.log("not supported");
}
Если есть какая-то проблема с браузером, о которой я не знаю, то использование .innerHTML
должно сделать то же самое.
var div = document.createElement("div");
div.innerHTML = "<input type='time'>";
if (div.firstChild.type === "time")
console.log("supported");
else
console.log("not supported");