Firefox 中的 Html 5 日期选择器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17292910/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:27:53  来源:igfitidea点击:

Html 5 datepicker in firefox

htmlgoogle-chromefirefox

提问by Aravind Bharathy

Is there any way that I can set enable a datepicker in firefox(version 21) with HTML 5. I dont want to use a jQuery based datepicker because javascript will be disabled in the browsers where the website will be used. The datepicker works fine with Chrome.

有什么方法可以设置启用带有 HTML 5 的 firefox(版本 21)中的日期选择器。我不想使用基于 jQuery 的日期选择器,因为 javascript 将在将使用网站的浏览器中禁用。日期选择器适用于 Chrome。

So if html 5 datepicker is not supported,how can I add a datepicker without jquery ?

因此,如果不支持 html 5 日期选择器,如何在没有 jquery 的情况下添加日期选择器?

采纳答案by Blazemonger

jQuery UI has a datepicker widget that you can conditionally load if the browser doesn't have one built in. The catch is that even if you onlyselect the datepicker widget in a custom jQuery UI build, it's still a significant download.

jQuery UI 有一个 datepicker 小部件,如果浏览器没有内置,您可以有条件地加载它。问题是即使在自定义 jQuery UI 构建中选择 datepicker 小部件,它仍然是一个重要的下载。

My favorite solution is to use yepnope, which comes with Modernizr, to conditionally load the jQuery UI CSS and JS files only ifneeded for the datepicker. By combining this with an optimized build of Modernizrand a datepicker-only jQuery UI build, it gives you the smallest download for all possible browsers.

我最喜欢的解决方案是使用yepnope,附带Modernizr的,有条件地加载jQuery UI的CSS和JS文件只有在需要的日期选择器。通过将其与Modernizr优化构建仅限日期选择器的 jQuery UI 构建相结合,它为所有可能的浏览器提供了最小的下载量。

yepnope({ /* included with Modernizr */
  test : Modernizr.inputtypes.date,
  nope : {
    'css': '/path-to-your-css/jquery-ui-1.10.3.custom.min.css',
    'js': '/path-to-your-js/jquery-ui-1.10.3.datepicker.min.js'
  },
  callback: { // executed once files are loaded
    'js': function() { $('input[type=date]').datepicker({dateFormat: "yy-mm-dd"}); } // default HTML5 format
  }
});

回答by Abel Pastur

Firefox 57 (Nov 14, 2017) supports it:

Firefox 57(2017 年 11 月 14 日)支持它:

http://caniuse.com/#feat=input-datetime

http://caniuse.com/#feat=input-datetime

回答by Stephanie Peters

Old question, but I found this here (firefox 54), at least, which gives hope:

老问题,但我在这里找到了这个(firefox 54),至少,这给了希望:

Go to about:config and search for dom.forms.datetime

转到 about:config 并搜索 dom.forms.datetime

Set both entries found to true, et voilà! Now all they need to do is enable them by default!

将找到的两个条目都设置为 true,等等!现在他们需要做的就是默认启用它们!

回答by maqjav

Firefox (version 21) doesn't support input type=date.

Firefox(版本 21)不支持input type=date.

Here you have a site that tells you what it supports and what it doesn't Firefox21

在这里你有一个网站,告诉你它支持什么,不支持什么Firefox21

回答by Max M.

Firefox 57 finally has a datepicker with a clickable calender (<input type="date">).

Firefox 57 终于有了一个带有可点击日历的日期选择器(<input type="date">)。

enter image description here

在此处输入图片说明

The timepicker is just a text field that limits input to valid times. Sadly, it only supports 12 hour time format (<input type="time">).

时间选择器只是一个将输入限制为有效时间的文本字段。遗憾的是,它只支持 12 小时时间格式(<input type="time">)。

enter image description here

在此处输入图片说明

datetime-local still isn't supported (<input type="datetime-local">).

仍然不支持 datetime-local (<input type="datetime-local">)。