HTML onchange / onblur compatibility

I am currently writing a website that should be compatible with all browsers, including IE, prior to version 6.

I was interested to learn about compatibility issues with these two events in particular: I use them tagged <input>with type='text'.

  • ONBLUR
  • Onchange

The search found mixed answers and an incomplete list.

In particular, the question arises:

  • Are there any known issues with the above two events (can be extended to other HTML events)?
  • If so, what methods can be used to solve these problems?

Any help is much appreciated :)

+3
source share
3 answers

, . QuirksMode, , IE .

JavaScript , , , IE - , . , JavaScript, jQuery, YUI, Dojo, MooTools, ExtJS Closure. , () . CodingHorror, , JavaScript, JavaScript , , , JavaScript.

, , , onchange onblur.

+9

, , Internet Explorer , this.

Javascript, , , IE ( ) , dojo. Dojo :

"" - Dojo Dijit, Dojo Core Dijit , 100% , , . , , , , Opera "Dijit", , , (, Opera).

, "" , ( Dojo 1.3.2) IE 6 8, Safari 3.1 4, Firefox 2 3.5, Chrome 1 2 ( , , Opera, Konqueror, FF 1.5,...).

+1

If you are using jQuery, try the following:

$('input.text').click(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
    });
    $('input.text').blur(function () {
        if (this.value === '') {
            this.value = this.defaultValue;
        }
    });

$("input:text")if you want to target all text input fields.

0
source

Source: https://habr.com/ru/post/1719480/


All Articles