IE输入类型“日期"未显示为“日期选择器" [英] IE Input type Date not appearing as Date Picker

查看:74
本文介绍了IE输入类型“日期"未显示为“日期选择器"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HTML中使用了输入类型DATE,并且在Chrome和Firefox中一切正常,但是IE并未显示日期选择器.

I am using the input type DATE in my HTML and everything works fine in Chrome and Firefox, but IE does not show the date picker.

当我使用JQuery Datepicker时,在Chrome和Firefox中会出现两个日期选择器对话框.

When I use the JQuery Datepicker I get two date picker dialogs in Chrome and Firefox.

如何修复可以具有日期输入类型且表单只有一个弹出窗口的功能?

How can I fix the functionality where I can have the date input type and only have one popup for my form?

推荐答案

您需要使用 polyfill ,以便输入类型DATE在所有浏览器中都具有一致的行为.您可以使用此 webshim 作为polyfill.

You need to use a polyfill so that the input type DATE has a consistent behaviour in all browsers. You can use this webshim as a polyfill.

输入类型DATE是HTML5功能,并非所有浏览器都支持.如果您要使用浏览器不支持的HTML5功能(通常是IE),请使用以下两项:

Input type DATE is an HTML5 feature which is not supported by all browsers. In case you want to use the HTML5 feature not supported by your browser (which usually will be IE) then use two things:

  • 特征检测
  • 填充

功能检测功能可以确定我们的浏览器是否支持HTML5功能.一个很好的库是 Modernizr .您可以使用modernizr进行的操作是检测是否不支持所需的任何功能,如果不支持,则可以有条件地加载一些将实现该功能的javascript库.这些库称为填充.

Feature Detection is the ability to determine if the HTML5 feature is supported or not by our browser. A good library for that is Modernizr. What you can do with modernizr is to detect if any feature that you need is not supported and if not then you can conditionally load some javascript libraries that will implement that feature. Those libraries are called Polyfills.

例如,如果您想在IE 10中使用标记,则可以使用jqueryui.com控件提供日期选择器.

So for example if you want to use the tag in IE 10 you could use the jqueryui.com controls to provide a date picker.

Modernizr.load({
    test: Modernizr.inputtypes.date,
    nope: "js/jquery-ui.custom.js",
    callback: function() {
      $("input[type=date]").datepicker();
    }
  });

Modernizr测试是否支持该功能,可选地,您可以使用nope指示是否存在仅在不支持该功能的情况下才要加载的库,并且回调是将在测试后调用的代码,并且加载库后.

Modernizr tests if the feature is supported, optionally you can use the nope to indicate if there is a library that you want to load ONLY if the feature is not supported, and callback is the code that will be called after the test and after loading the library.

这篇关于IE输入类型“日期"未显示为“日期选择器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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