I want to check in my website, if the visitors browser support a HTML5 input type. How should I do it?
You could do:
function IsAttributeSupported(tagName, attrName) { var val = false; // Create element var input = document.createElement(tagName); // Check if attribute (attrName) // attribute exists if (attrName in input) { val = true; } // Delete "input" variable to // clear up its resources delete input; // Return detected value return val; } if (!IsAttributeSupported("input", "placeholder")) { // Do something special here alert("placeholder attribute is not supported"); }
Hope it helps