Trying to handle window.onreadystatechange
, I notice this event firing two times during page load. But I cannot figure out what exactly becomes changed after each event. If it were not for window
, but for document
, then there had been document.readyState
property containing the current state. But in case of window
, there isn’t any “window.readyState”
or similar property. So what does it really mean when a readystatechange
event for window
fires, and what the difference between the first and the second firing is?
Here is my code that gives two seemingly identical console outputs:
'use strict';
window.addEventListener('readystatechange', function(e) {
console.log(window, e);
});
readyState
property andreadystatechange
event fordocument
, but my question was about handling this event forwindow
, not fordocument
. – Tulatulipe
? – Parmenides__proto__
isEvent.prototype
andcurrentTarget
iswindow
. But what aretarget
andsrcElement
, do they refer todocument
? – Parmenidestarget
andsrcElement
both refer todocument
, whilecurrentTarget
iswindow
. – Tulatulipbubbles
istrue
, which confirms @Kaiido's theory. Although it shouldn't. And really not fromdocument
towindow
. Looks like a bug to me. – Parmenides