...">

Should the fire be washed or washed first?

<!doctype html> <body> <input onblur="alert('b');"> <button onmousedown="alert('m');">a</button> </body> 

For some reason, the blur seems to work first on FF / IE (but mousedown seems to start on Chrome / Safari first).

But when we change the code to this:

 <!doctype html> <body> <input onblur="document.title+='b';"> <button onmousedown="document.title+='m';">a</button> </body> 

Now for some reason, mousedown seems to be launched first for all browsers.

1) What could be the explanation for this abnormality?

2) Based on W3C specs, which should be standard behavior?

+7
source share
2 answers

So, for this test I did this fiddle

 <input onblur="document.getElementById('msg').innerHTML+=new Date().getTime()+' - blur<br/>'"> <button onmousedown="document.getElementById('msg').innerHTML+=new Date().getTime()+' - md<br/>'">a</button> <div id="msg">---<br/></div> 

In Windows XPsp3, in Fx5, IE8, Opera 11, Safari5, Chrome 13 first EVERYTHING, mwedown, is blurred after

UPDATE: EXCEPT when you use the warning. You cannot count on anything working the way you want it if you put a warning somewhere.

For example, some (older) browsers went into an endless loop if you warned about the onblur error, and then tried to focus the violation field, which then blurs the next blank field

+10
source

Oh my gosh, this is an endless story. I do not want to know how many hours I spent to correctly evaluate this behavior. As you mentioned, this behaves differently, so there really isn’t any “right ones”. However, I am not so knowledgeable about the W3C specification about this particular instance (if you have one thing?), But in order to know, you need to create some logic so that things run in the correct order. This is pretty disgusting.

+1
source

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


All Articles