最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Prevent Opera browser from enriching HTML5 fields - Stack Overflow

programmeradmin1浏览0评论

I'm using loads of inputs with HTML5 types (such as 'date' or 'time') using the jQuery Tools library. Some browsers (like Opera) automatically recognize that and, for example, transform the <input type="time" /> into a time input.

However, I do not want that behavior (since Opera's time input does not include seconds). Is there any mon HTML5 way of disabling such special behavior?

Thanks, Remo

I'm using loads of inputs with HTML5 types (such as 'date' or 'time') using the jQuery Tools library. Some browsers (like Opera) automatically recognize that and, for example, transform the <input type="time" /> into a time input.

However, I do not want that behavior (since Opera's time input does not include seconds). Is there any mon HTML5 way of disabling such special behavior?

Thanks, Remo

Share Improve this question edited Feb 15, 2011 at 13:41 Jakub Hampl 40.6k10 gold badges79 silver badges111 bronze badges asked Feb 15, 2011 at 13:39 RemoRemo 633 bronze badges 6
  • 7 That's the purpose of the html5 types to have special UI - the simplest way is to use other types - like just type=text. – Jakub Hampl Commented Feb 15, 2011 at 13:42
  • 1 As Jakub said, those types ARE the "HTML5 way" of doing things. Use CSS classes and then do whatever you want to to the elements with jQuery. – Sapph Commented Feb 15, 2011 at 13:47
  • 3 Calling 'HTML classes' 'CSS classes' makes even less sense when you're only dealing with them in the context of JavaScript. sigh. – Quentin Commented Feb 15, 2011 at 13:49
  • i really don't have a problem with opera here, since their implementation is good, i hate the way chrome handles html5 form fields, especially date, its terrible – Hannes Commented Feb 15, 2011 at 14:00
  • Chrome also doesn't show deconds. Seems like type='time' might not be the right feature for you (at least not until it's more customisable). Just use type='text'. – Spudley Commented Feb 15, 2011 at 14:14
 |  Show 1 more ment

2 Answers 2

Reset to default 9

If you want a time element on Opera to display seconds, add the attribute step="1", you can get milliseconds by setting step="0.1" and step=60 will give you the default hh:mm again. This also works in Chrome (tested in 9.0.597.98 beta).

As most of the menters on the original question already stated: No, there is no "mon HTML5 way" to prevent this behavior.

Even if so, you shouldn't. You're effectivly asking Opera to ignore something you asked for in the first place: a special UI.

发布评论

评论列表(0)

  1. 暂无评论