最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Detect browser's native datetime pickers - Stack Overflow

programmeradmin9浏览0评论

For a mobile html5/js website I would like to leverage native browser date/time pickers when available (like on mobile safari for instance). I know I can detect if the browser supports the date/datetime input types, which will help ensure the proper data format is entered, but is there a proper way to detect if the current browser offers native date and/or time picker?

For a mobile html5/js website I would like to leverage native browser date/time pickers when available (like on mobile safari for instance). I know I can detect if the browser supports the date/datetime input types, which will help ensure the proper data format is entered, but is there a proper way to detect if the current browser offers native date and/or time picker?

Share Improve this question asked Oct 23, 2012 at 7:01 RomainRomain 1,3021 gold badge10 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

you can create an input element and try to assign the type, if it's not supported the type will switch back to the default type (which is text)

function isDateSupported() {
    var i = document.createElement("input");
    i.setAttribute("type", "date");
    return i.type !== "text";
}

or you can use a tool like modernizr

发布评论

评论列表(0)

  1. 暂无评论