What's IE take on HTMLDocument and HTMLElement

前端 未结 1 653
野性不改
野性不改 2021-02-19 17:51

Within javascript\'s scope, referring to HTMLDocument or HTMLElement raises error on IE8.

The error I get is \"HTMLElement is undefined\".

What is the way to ha

1条回答
  •  走了就别回头了
    2021-02-19 18:38

    In IE8 you have to use the Element and HTMLDocument classes. In IE7... nothing, because IE7 is terrible for standards. You have to rely on jQuery or other frameworks that wrap DOM elements.

    In my own framework I make this simple check:

    var elementPrototype = typeof HTMLElement !== "undefined"
            ? HTMLElement.prototype : Element.prototype;
    

    Mind you that it's not a framework for IE7 and lower.

    0 讨论(0)
提交回复
热议问题