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

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

问题描述

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



如何获得 type =date (即 jQueryUI DatePicker Widget)只是为了得到一个日历/日期只是IE浏览器和Firefox浏览器?有没有什么可以应用在某个地方(CDN也许?),这将使这个功能默认在Firefox和/或IE浏览器?试图瞄准IE 8 +浏览器和Firefox,没关系,最新版本(28.0)将罚款。


$ b

更新:Firefox 57 +支持输入类型=日期 rel =noreferrer> webshims ,可在 cdn 上找到+ only loading如果需要,可以使用polyfill。

以下是CDN演示:
http://jsfiddle.net/trixta/BMEc9/

 <! -  cdn for modernizr,if你还没有包括它 - > 
< script src =http://cdn.jsdelivr.net/webshim/1.12.4/extras/modernizr-custom.js>< / script>
<! - 用于检测和加载polyfills的polyfiller文件 - >
< 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/>

如果默认配置不满足,有多种配置方式。您可以在这里找到日期选择器配置器



注意:虽然未来可能会有针对webshim的新bug修复版本。将不会有任何重大的发布。这包括对jQuery 3.0或任何新功能的支持。


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...

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.

UPDATE: Firefox 57+ supports input type=date

解决方案

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

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" />

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

Note: While there might be new bugfix releases for webshim in the future. There won't be any major releases anymore. This includes support for jQuery 3.0 or any new features.

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

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