Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's IE take on HTMLDocument and HTMLElement

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 have JS interacting with native DOM object of this browser?

like image 706
Tzury Bar Yochay Avatar asked Jun 03 '12 07:06

Tzury Bar Yochay


1 Answers

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.

like image 101
MaxArt Avatar answered Oct 07 '22 04:10

MaxArt