internet explorer 8 - Javascript "Member not found" error in IE8 - Stack Overflow

I'm trying to debug the following block of Javascript code to see what the issue is. I'm gett

I'm trying to debug the following block of Javascript code to see what the issue is. I'm getting an error that says "Member not found" on the line

constructor = function() {
in the extend:function() method.

I'm not very good with Javascript, and I didn't write this, so I'm kind of lost on what the issue is. The error only occurs in IE8, it works fine in IE7 and Firefox.

var Class = {
  create: function() {
    return function() {
        if(this.destroy) Class.registerForDestruction(this);
          if(this.initialize) this.initialize.apply(this, arguments);
      }
  },

  extend: function(baseClassName) {
    constructor = function() {
        var i;

          this[baseClassName] = {}
        for(i in window[baseClassName].prototype) {
            if(!this[i]) this[i] = window[baseClassName].prototype[i];
            if(typeof window[baseClassName].prototype[i] == 'function') {
                this[baseClassName][i] = window[baseClassName].prototype[i].bind(this);
            }
        }

        if(window[baseClassName].getInheritedStuff) {
            window[baseClassName].getInheritedStuff.apply(this);
        }

        if(this.destroy) Class.registerForDestruction(this);
          if(this.initialize) this.initialize.apply(this, arguments);
    }

    constructor.getInheritedStuff = function() {
        this[baseClassName] = {}
        for(i in window[baseClassName].prototype) {
            if(!this[i]) this[i] = window[baseClassName].prototype[i];
            if(typeof window[baseClassName].prototype[i] == 'function') {
                this[baseClassName][i] = window[baseClassName].prototype[i].bind(this);
            }
        }

        if(window[baseClassName].getInheritedStuff) {
            window[baseClassName].getInheritedStuff.apply(this);
        }
    }

    return constructor;

  },

  objectsToDestroy : [],  
  registerForDestruction: function(obj) {
    if(!Class.addedDestructionLoader) {
            Event.observe(window, 'unload', Class.destroyAllObjects);
        Class.addedDestructionLoader = true;
    }
    Class.objectsToDestroy.push(obj);
  },

  destroyAllObjects: function() {
    var i,item;
    for(i=0;item=Class.objectsToDestroy[i];i++) {
        if(item.destroy) item.destroy();
    }
    Class.objectsToDestroy = null;
  }  
}

I'm trying to debug the following block of Javascript code to see what the issue is. I'm getting an error that says "Member not found" on the line

constructor = function() {
in the extend:function() method.

I'm not very good with Javascript, and I didn't write this, so I'm kind of lost on what the issue is. The error only occurs in IE8, it works fine in IE7 and Firefox.

var Class = {
  create: function() {
    return function() {
        if(this.destroy) Class.registerForDestruction(this);
          if(this.initialize) this.initialize.apply(this, arguments);
      }
  },

  extend: function(baseClassName) {
    constructor = function() {
        var i;

          this[baseClassName] = {}
        for(i in window[baseClassName].prototype) {
            if(!this[i]) this[i] = window[baseClassName].prototype[i];
            if(typeof window[baseClassName].prototype[i] == 'function') {
                this[baseClassName][i] = window[baseClassName].prototype[i].bind(this);
            }
        }

        if(window[baseClassName].getInheritedStuff) {
            window[baseClassName].getInheritedStuff.apply(this);
        }

        if(this.destroy) Class.registerForDestruction(this);
          if(this.initialize) this.initialize.apply(this, arguments);
    }

    constructor.getInheritedStuff = function() {
        this[baseClassName] = {}
        for(i in window[baseClassName].prototype) {
            if(!this[i]) this[i] = window[baseClassName].prototype[i];
            if(typeof window[baseClassName].prototype[i] == 'function') {
                this[baseClassName][i] = window[baseClassName].prototype[i].bind(this);
            }
        }

        if(window[baseClassName].getInheritedStuff) {
            window[baseClassName].getInheritedStuff.apply(this);
        }
    }

    return constructor;

  },

  objectsToDestroy : [],  
  registerForDestruction: function(obj) {
    if(!Class.addedDestructionLoader) {
            Event.observe(window, 'unload', Class.destroyAllObjects);
        Class.addedDestructionLoader = true;
    }
    Class.objectsToDestroy.push(obj);
  },

  destroyAllObjects: function() {
    var i,item;
    for(i=0;item=Class.objectsToDestroy[i];i++) {
        if(item.destroy) item.destroy();
    }
    Class.objectsToDestroy = null;
  }  
}
Share Improve this question edited Mar 23, 2010 at 15:22 Svante Svenson 12.5k4 gold badges43 silver badges46 bronze badges asked Mar 23, 2010 at 15:17 StevenSteven 18.9k74 gold badges204 silver badges303 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 3

One immediate problem I see is that "constructor" is a global variable. Use "var constructor = function..." to give it local scope.

This may not be the issue, but you probably want to make construct variable local by using var statement.

var constructor = function() { ...

i had the same problem. IE8 treats 'class' variable as a method and freeze. Try to rename it to something else

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745301902a4621483.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信