gpt4 book ai didi

javascript - "' HTMLDocument ' is undefined"在 IE8 中

转载 作者:行者123 更新时间:2023-11-28 20:08:08 24 4
gpt4 key购买 nike

我环顾四周,到处都说 IE8 确实有 HTMLDocument 和 Element 类。不幸的是,当我尝试访问它时,我得到的只是:

"'HTMLDocument' is undefined"
"'HTMLElement' is undefined"
"'Element' is undefined"
"'Document' is undefined"

我一直怀疑这是控制台的错误,但是当我从脚本和原型(prototype)加载它时,同样的事情发生了,即数组确实正常存在。

我是否尝试以错误的方式访问它?我正在使用:

typeof HTMLDocument.prototype.getElementsByClassName != 'function'

最佳答案

我不确定,但可能是,那是因为您处于兼容模式。

你可以做这样的事情:

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

但这适用于 IE7+

关于javascript - "' HTMLDocument ' is undefined"在 IE8 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20400026/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com