【问题标题】:getElementsBySelector failing in IE 8getElementsBySelector 在 IE 8 中失败
【发布时间】:2014-12-05 01:11:51
【问题描述】:

我正在处理 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.wrapper.querySelectorAll('div.elscroller');
    }
    this.sections   = this.wrapper.getElementsBySelector('div.seccion');

这在 Chrome 和 Firefox 中运行良好,但 IE 抛出:Object doesn't support this property or method in this line: 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。我希望有一天人们停止使用这个#%!浏览器。

【问题讨论】:

  • 什么返回$.toSring();?
  • @plalx 它返回:错误:对象不支持此属性或方法并停止解析

标签: javascript html internet-explorer internet-explorer-8 prototypejs


【解决方案1】:

如果您使用 PrototypeJS,那么您可以这样做,这将适用于所有浏览器

this.sections   = this.wrapper.select('div.seccion');

this.sections 将是与 CSS 选择器 div.seccion 匹配的 DOM 元素数组

【讨论】:

  • 这会抛出:对象不支持此属性或方法。我根本不知道这个浏览器会发生什么
  • select() 是一个 PrototypeJS 方法 - 你确定你正在加载原型框架吗?您正在加载最新版本(2014 年 4 月 1.7.2 日)。
猜你喜欢
  • 1970-01-01
  • 2011-06-22
  • 2012-06-01
  • 1970-01-01
  • 2010-10-06
  • 2012-02-28
  • 1970-01-01
  • 1970-01-01
  • 2011-01-22
相关资源
最近更新 更多