什么是IE对HTMLDocument和HTMLElement [英] What's IE take on HTMLDocument and HTMLElement

查看:185
本文介绍了什么是IE对HTMLDocument和HTMLElement的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript范围内,请参阅 HTMLDocument HTMLElement 引发IE8上的错误。

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

我得到的错误是HTMLElement is undefined。

The error I get is "HTMLElement is undefined".

有什么方法让JS与本机的DOM对象进行交互浏览器?

What is the way to have JS interacting with native DOM object of this browser?

推荐答案

在IE8中,您必须使用元素 code> HTMLDocument 类。在IE7 ...没什么,因为IE7是可怕的标准。您必须依靠jQuery或其他包装DOM元素的框架。

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;

请注意,这不是IE7及更低版本的框架。

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

这篇关于什么是IE对HTMLDocument和HTMLElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆