用于 IE7 元素的类是什么?

在大多数浏览器中,document.createElement("div") instanceof HTMLElement 将是 true。要支持某些 IE 浏览器,您必须执行 document.createElement("div") instanceof (window.HTMLElement||window.Element) 以正确检查它是否是一个元素。

这在 IE7 之前有效,其中 window.HTMLElement window.Elementundefined,因此导致以下错误。

Invalid operand to 'instanceof': Function expected

我尝试搜索 window 对象,但它没有列出内置类,我也尝试使用 Object.getPrototypeOf 失败,因为它不存在。 Searching on Google 没有给出想要的结果。

我也不想使用 .nodeType,因为那样 {nodeType:1} 会被错误地视为一个元素。

我应该用什么来检查 IE7 中的元素?

ioublack 回答:用于 IE7 元素的类是什么?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/613.html

大家都在问