Is there really no way to expose the prototype of a html element in IE (<8)?

前端 未结 3 2046
刺人心
刺人心 2020-11-30 14:01

I cooked up a pattern to create and extend html elements using their prototype. This works like a charm in non-ie browsers. Example code can be found @jsbin (see page source

3条回答
  •  悲&欢浪女
    2020-11-30 14:53

    Yes there really is no way to do this.

    IE elements are based COM objects which actually don't allow arbitary members to be added to their interfaces (in COM, interfaces are a contract and should never change). Implementation of these interfaces cannot be extended by Javascript, the elements simply are not prototypal.

    IE adds a special interface designed to work with Javascript to allow the addition of new members to a specific instance but you cannot add a new member to 'class' since there is no prototype to fiddle with.

提交回复
热议问题