Html 5 datepicker在Firefox [英] Html 5 datepicker in firefox

查看:136
本文介绍了Html 5 datepicker在Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法,我可以设置启用日期选择器在Firefox 5(版本21)与HTML 5.我不想使用基于jQuery的日期选择器,因为JavaScript将被禁用在浏览器中的网站将被使用。日期选择器可以正常工作。



所以,如果不支持HTML 5的日期选择器,我该如何添加一个没有jQuery的日期选择器?

仅限于 在自定义jQuery UI版本中选择datepicker小部件,它仍然是一个重大的下载。



我最喜欢的解决方案是使用yepnope,它与 Modernizr ,只有当datepicker需要时,才有条件地加载jQuery UI CSS和JS文件。通过将其与 Modernizr的优化版本仅限日期选择器的jQuery UI构建,它为您提供所有可能浏览器的最小下载

  yepnope({/ *包含在Modernizr * / 
test中:Modernizr.inputtypes.date,
nope:{
'css':'/path-to-your-css/jquery-ui-1.10.3.custom.min.css',
'js':'/ path-to你的js / jquery-ui-1.10.3.datepicker.min.js'
},
回调:{//执行一次文件加载
'js':function() {$('input [type = date]')。datepicker({dateFormat:yy-mm-dd});} //默认HTML5格式
}
});


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.

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

解决方案

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 only select the datepicker widget in a custom jQuery UI build, it's still a significant download.

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

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
  }
});

这篇关于Html 5 datepicker在Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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