What does “self” mean in javascript?

Other replies have pointed out that self is not going to refer to the FORM and that self is window. They’re right; self is window. Well, except when it isn’t. In either IE6 or IE7 (forgot), self.onload would not fire, though window.onload would.

All official versions of IE (and even IE9pr3) have an odd, intransitive implementation of == with these host objects. Using == to compare either window or self to a node in the document, the result is true.

IE Oddities

alert(self == document.body); // true
alert(document.body == self); // false
alert(window == self); // true
alert(window === self); //false
var b = document.createElement("b");
alert(window == b); // false
alert(window == document.body.appendChild(b)); // true
alert(window == document.body.removeChild(b)); // false

Leave a Comment

techhipbettruvabetnorabahisbahis forumuedueduedusedueduedusedusedusedusedu