Html 日期选择器 html5 标签不适用于 Mozilla、IE 浏览器。但它仅适用于 Chrome
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24553135/
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
Date picker html5 tag is not working on Mozilla, IE browsers. But its working only on Chrome
提问by user3801514
I am trying to use HTML 5 Date picker tag in my website. But this tag is not supporting on Mozilla & IE. Can you please share me any hack to work this code in IE and Mozilla.
我正在尝试在我的网站中使用 HTML 5 日期选择器标签。但是这个标签在 Mozilla 和 IE 上不支持。你能分享我在 IE 和 Mozilla 中使用此代码的任何技巧吗?
I want to use only HTML5. i don't want to go for JavaScript.
我只想使用 HTML5。我不想使用 JavaScript。
回答by Tom Maton
Date is only supported in Chrome, Opera, Safari and Android Browser 4.4+
日期仅在 Chrome、Opera、Safari 和 Android 浏览器 4.4+ 中受支持
回答by Harmeet Singh
You can user jQuery date picker in case of Mozilla: Check the browser using $.browser.mozilla but it will not work in jQuery>1.9, so you have to use jQuery Migration as shown below:
在 Mozilla 的情况下,您可以使用 jQuery 日期选择器:使用 $.browser.mozilla 检查浏览器,但它在 jQuery>1.9 中不起作用,因此您必须使用 jQuery Migration,如下所示:
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>//jQuery migration
<script>
if ($.browser.mozilla)
{
if ($('.datepicker')[0].type != 'date') $('.datepicker').datepicker();
$(function () {
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
yearRange: "1900:2015",
dateFormat: "yy-mm-dd",
defaultDate: '1900-01-01'
});
});
}
</script>
回答by Pardeep Jain
Yes DatePicker
tag of HTML5 is not supported by Mozilla Firefox. But you can use DatePicker
in your website by adding few .js files.
DatePicker
Mozilla Firefox 不支持 HTML5 的Yes标签。但是您可以DatePicker
通过添加几个 .js 文件在您的网站中使用。
Below is my fiddle using some .js files. this code work properly on Chrome as well as Mozilla.
下面是我使用一些 .js 文件的小提琴。这段代码在 Chrome 和 Mozilla 上都能正常工作。
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<p>Your Selected date Is : <input type="text" id="datepicker"></p>
回答by Serj Sagan
1st, to answer the OP, what the asker is asking to do is impossible. Javascript
is required. 2nd, although webshim
looks great, it works horribly with bootstrap
. For that you'll want to use http://eonasdan.github.io/bootstrap-datetimepicker/
第一,要回答 OP,提问者要求做的事情是不可能的。Javascript
是必须的。第二,虽然webshim
看起来不错,但与bootstrap
. 为此,您需要使用http://eonasdan.github.io/bootstrap-datetimepicker/
回答by alexander farkas
Simply use a datepicker polyfill. here is a demo.
只需使用日期选择器 polyfill。这是一个演示。
<script src="js/jquery.js"></script>
<script src="js-webshim/minified/polyfiller.js"></script>
<script>
//webshim.setOptions('basePath', '/js-webshim/minified/shims/');
//request the features you need:
webshim.polyfill('es5 mediaelement forms');
$(function(){
// use all implemented API-features on DOM-ready
});
</script>
<input type="date" />
回答by eirenaios
Dont forget doctype like this:
不要忘记这样的文档类型:
<!DOCTYPE html>
<html>
<body>
<form action="demo_form.asp">
Birthday: <input type="date" name="bday">
<input type="submit">
</form>
</body>
</html>
Firefox and mozilla does not not supporting Date-HTML5 ! It will support soon.
Firefox 和 mozilla 不支持 Date-HTML5 !很快就会支持。
But it will work smoothly on Google-Chrome, Opera and Safari
但它会在Google-Chrome、Opera 和 Safari上顺利运行