As we all know, IE8 has opened support for DOM prototype and two new methods of ECMAv5-Object. defineProperty and Object. getOwnPropertyDexcriptor (long words ......), And the two new methods can only be used for DOM. Microsoft's intention to do this is obvious-"implementing" all DOM2 interfaces at a very small cost. Here are two examples:
The Code is as follows:
Element. prototype. addEventListener = function (evtType, evtHandler ){
Return this. attachEvent ('on' + evtType, evtHandler );
}
Object. defineProperty (Event. prototype, 'target ',{
Get: function () {return this. srcElement },
Set: function (v) {return this. srcElement = v}
});
This seems to be the same as using the _ definegetter _ stream in earlier years to make Firefox compatible with IE methods, but this time it is completely standard (DOM prototype and ECMA v5) to make up for the shortcomings of IE. Maybe the rendering engine was rewritten during IE8 development, but it didn't come (I'm optimistic ......) This solution is provided to publish a new DOM interface (probably to be compatible with third-party applications.