Javascript getElementsBySelector在IE 8中失败
我正在处理Internet Explorer 8,我有以下代码:Javascript getElementsBySelector在IE 8中失败,javascript,html,internet-explorer,internet-explorer-8,prototypejs,Javascript,Html,Internet Explorer,Internet Explorer 8,Prototypejs,我正在处理Internet Explorer 8,我有以下代码: this.scrolling = false; this.wrapper = $(wrapper); //this.scroller = this.wrapper.down('div.elscroller'); if (this.wrapper.querySelectorAll('div.elscroller') != null ) { this.scroller = this.
this.scrolling = false;
this.wrapper = $(wrapper);
//this.scroller = this.wrapper.down('div.elscroller');
if (this.wrapper.querySelectorAll('div.elscroller') != null ) {
this.scroller = this.wrapper.querySelectorAll('div.elscroller');
}
this.sections = this.wrapper.getElementsBySelector('div.seccion');
这在Chrome和Firefox中运行良好,但IE抛出:Object不支持此行中的此属性或方法:This.sections=This.wrapper.getElementsBySelector('div.seccion')代码>
HTML代码如下所示:
<div class="elscroller">
<div class="seccion" id="seccion1"></div>
<div class="seccion" id="seccion..n"></div>
</div>
正如你所看到的,有一行被注释了,因为它有同样的问题,所以我采用了一种原始的方法来做事情,并在那里放置了一个if。只有上帝知道怎么做,但它起了作用
我真的厌倦了为IE8编写代码。我希望有一天人们停止使用这个#%!浏览器。如果您使用的是PrototypeJS,那么您可以使用这种方式,这种方式将适用于所有浏览器
this.sections = this.wrapper.select('div.seccion');
this.sections
将是一个DOM元素数组,与CSS选择器div.seccion
返回的内容$.tostring()代码>?@plalx返回:错误:对象不支持此属性或方法并停止解析此抛出:对象不支持此属性或方法。我根本不知道这个浏览器会发生什么select()
是一个PrototypeJS方法-你确定要加载原型框架吗?您正在加载最新版本(2014年4月1.7.2日)。