如何获取 HTML 5 输入类型 =“日期"在 Firefox 和/或 IE 10 中工作 [英] How to get HTML 5 input type="date" working in Firefox and/or IE 10

查看:22
本文介绍了如何获取 HTML 5 输入类型 =“日期"在 Firefox 和/或 IE 10 中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得很奇怪,input type="date" 在这么长时间之后仍然不受 Firefox 支持.事实上,我不认为他们在输入元素上添加了很多(如果有的话)HTML 5 新类型.IE10 不支持它并不奇怪.所以,我的问题是...

I find it odd that input type="date" is still not supported in Firefox after all of this time. In fact, I don't think they added in much (if any) of the HTML 5 new types on an input element. Not surprised that it is not supported in IE10. So, my question is...

如何让 type="date"input 元素上工作而不添加另一个 .js 文件(即 jQueryUI DatePickerWidget) 只是为了获取仅适用于 IE 和 Firefox 浏览器的日历/日期?有没有什么东西可以应用在某个地方(也许是 CDN?),可以让这个功能在 Firefox 和/或 IE 浏览器中默认工作?尝试针对 IE 8+ 浏览器和 Firefox,没关系,最新版本 (28.0) 就可以了.

How to get type="date" on an input element working without adding, yet another, .js file (namely jQueryUI DatePicker Widget) just to get a calendar/date for only IE and Firefox Browsers? Is there something out there that can be applied somewhere (CDN perhaps?) that will make this functionality work by default in Firefox and/or IE Browsers?? Trying to target IE 8+ Browsers and for Firefox, doesn't matter, newest version (28.0) will be fine.

更新:Firefox 57+ 支持输入类型=日期

UPDATE: Firefox 57+ supports input type=date

推荐答案

你可以试试 webshims,可在 cdn 上使用 + 仅加载 polyfill(如果需要).

You can try webshims, which is available on cdn + only loads the polyfill, if it is needed.

这是 CDN 的演示:http://jsfiddle.net/trixta/BMEc9/

Here is a demo with CDN: http://jsfiddle.net/trixta/BMEc9/

<!-- cdn for modernizr, if you haven't included it already -->
<script src="http://cdn.jsdelivr.net/webshim/1.12.4/extras/modernizr-custom.js"></script>
<!-- polyfiller file to detect and load polyfills -->
<script src="http://cdn.jsdelivr.net/webshim/1.12.4/polyfiller.js"></script>
<script>
  webshims.setOptions('waitReady', false);
  webshims.setOptions('forms-ext', {types: 'date'});
  webshims.polyfill('forms forms-ext');
</script>

<input type="date" />

如果默认配置不满足,有多种配置方式.在这里您可以找到 datepicker 配置器.

In case the default configuration does not satisfy, there are many ways to configure it. Here you find the datepicker configurator.

注意:虽然将来可能会有针对 webshim 的新错误修复版本.不会再有大版本了.这包括对 jQuery 3.0 或任何新功能的支持.

这篇关于如何获取 HTML 5 输入类型 =“日期"在 Firefox 和/或 IE 10 中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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