html onchange / onblur兼容性 [英] html onchange/onblur compatibility

查看:312
本文介绍了html onchange / onblur兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在编写一个网站,它必须与所有浏览器兼容,包括IE浏览器到第6版。



我想知道这两个事件的兼容性问题特别是:
我将它们与< input> 标签一起用于 type ='text'


  • OnBlur

  • OnChange



搜索已找到混合响应和不完整列表。



具体而言,问题是:


  • 上述两个事件是否存在任何已知问题(可扩展为其他HTML事件)?
  • 如果是这样,可以使用哪些方法解决这些问题?


任何帮助我们都非常感谢:) >解决方案

如果您只在文本框中使用它们,所有浏览器都应该很好地支持这些事件。如果您查看 QuirksMode事件兼容性表,您会看到IE如果您对浏览器中的JavaScript事件不熟悉,那么您会发现事件模型由于IE决定以不同于标准的方式做事,这是一团糟。为了克服这个问题,您应该使用JavaScript框架 jQuery YUI Dojo MooTools ExtJS 关闭。这些框架消除了差异,因此您几乎不需要处理差异和问题。错误在不同的浏览器中。 关于CodingHorror的一篇很棒的文章解释了为什么你应该考虑使用JavaScript框架如果您打算在您的网站上使用JavaScript,那么您应该阅读,如果您对为什么您应该使用JavaScript框架感到好奇。



此外,如果您完全不熟悉浏览器事件,请确保您了解 onchange和onblur之间的区别


I am currently writing a web site which must be compatible with all browsers including IE back to version 6.

I was wondering about compatibility issues with these two events in particular: I am using them with a <input> tag with type='text'.

  • OnBlur
  • OnChange

Searching has found mixed responses and an incomplete list.

Specifically, the question is:

  • Are there any known issues with the above two events (could be expanded to other HTML events)?
  • If so, what methods can be used to work around these issues?

Any help much appreciated :)

解决方案

All browsers should support these events pretty decently if you're only using them in text boxes. If you check out the QuirksMode event compatibility tables, you'll see that IE has some issues with the change event in radio buttons and check boxes.

If you're not very familiar with JavaScript events in browsers, you'll find that the event model is a mess thanks to the fact that IE decided to do things differently from the standard. To overcome this problem, you should be using a JavaScript framework like jQuery, YUI, Dojo, MooTools, ExtJS, or Closure. These frameworks smooth out the differences so you'll (almost) never have to deal with the differences & bugs in the different browsers. There is a great article on CodingHorror explaining why you should consider using a JavaScript framework if you plan on using JavaScript in your site that you should read if you're curious as to why you should use a JavaScript framework.

Also, if you're unfamiliar with browser events entirely, make sure you understand the difference between onchange and onblur.

这篇关于html onchange / onblur兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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