检查浏览器是否支持HTML5时间戳 [英] Check if Browser Supports HTML5 timepicker

查看:114
本文介绍了检查浏览器是否支持HTML5时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用JavaScript构建了一个时间掩码,适用于PC,Mac,iPhone和iPad,但在大多数Android手机中都不能保持一致(我不想深入了解为什么这个功能可以'在Android中持续工作)所以我禁用它。对于三星而言,内置的HTML5时间选择器效果很好。

I built a time mask in JavaScript which works great for PC's, Macs, iPhones, and iPads, but doesn't work consistently in most Android phones (I'd prefer not to get into the details of why this functionality can't work consistently in Android) so I disable it. For Samsung the built-in HTML5 time picker works great.

对于Android手机,我想利用HTML5时间选择器,当本机浏览器时间选择器可用时(例如现代三星手机)。

For Android phones I would like to leverage the HTML5 time pickers, when native browser time pickers are available (like for modern Samsung phones).

我知道我可以检测浏览器是否支持 date / datetime 输入类型,但这并不一定表明浏览器支持时间选择器(对于任何怀疑使用HTC EVO 3D进行测试的人,仅作为一个示例。)此问题(检测浏览器的本机日期/时间选择器)表示如果支持时间类型则浏览器已实现时间选择器,但这是错误的。

I know I can detect if the browser supports the date/datetime input types, but that doesn't necessarily indicate that the browser supports a time picker (For anyone who doubts this test it with an HTC EVO 3D, as just one example.) This Question ( Detect browser's native date/time pickers ) indicates that the if the time type is supported then the browser has implemented a time picker, but this is wrong.

我知道现代化,但我没有看到实际验证浏览器是否支持时间戳的方法。

I'm aware of modernizr but I don't see a way to actually verify if the browser supports a timepicker.

那么背景信息。有谁知道确定浏览器是否实施了时间选择器的方法?

So with that background information. Does anyone know of a way to determine if the browser has implemented a time picker?

推荐答案

我认为最安全的赌注实际上是假设< input type =date > 不受支持。截至今天(2016年初),日期选择器的实际UI在各浏览器之间仍然非常不一致。除非您正在为一个非常具体的浏览器子集开发,否则无论如何都需要一些JavaScript。

I would argue that the safest bet is actually to assume that <input type="date"> is unsupported. As of today (early 2016), the actual UI for the date picker is still very inconsistent across browsers. Unless you're developing for a very concrete subset of browsers you are going to need some JavaScript anyway.

参考文献:

  • http://html5doctor.com/the-woes-of-date-input
  • http://caniuse.com/#feat=input-datetime

这篇关于检查浏览器是否支持HTML5时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆