Home > Web Front-end > JS Tutorial > body text

Let IE8 support DOM 2 (without framework!)_javascript skills

WBOY
Release: 2016-05-16 18:37:40
Original
1196 people have browsed it

Microsoft's intention for this move is obvious - to "implement" all the interfaces of DOM2 at a very small cost. Here are two examples:

Copy code 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 __definegetter_ in the early years _ and others make Firefox compatible with IE in the same way, but this time they use a completely standard (DOM prototype and ECMA v5) method to make up for the shortcomings of IE. Maybe the rendering engine was rewritten during the development of IE8 but there was no time (I'm very optimistic...) to release a new DOM interface (maybe to be compatible with third-party applications), so this solution was given.
Related labels:
ie8
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template