Javascript – Object doesn’t support this property or method javascript error in IE6 only

internet-explorer-6javascriptobject

I've searched the internet and this great stackoverflow.com site particularly, but cannot help myself. I am not very experienced programmer and a friend of mine asked me to fix the bug that is on IE6 only. It works on FF, IE7/8, Opera.
Here is the PART of the code that gives error message on IE6:

(function(d, n, r) {
  var ie, jscript, settings = {};
  function add(element, type, listener) { element.addEventListener(type, listener, false); };
  function remove(element, type, listener) { element.removeEventListener(type, listener, false); };
  var l = {change:[], ready:[], load:[]};
  a11y = function(f) {
    a11y.change(f);
  };
})
(self.document, self.navigator);

The error is on line 7: a11y.change(f); All other browsers are OK, just IE6. I am not author of the script, just trying to fix this. Can anybody help, please? There must be some problem with function declaration or…?

Best Answer

The example looks pretty confused there is a lot of code there that looks to be a distraction.

From what I can see the problem is in this code:

a11y = function(f) {
    a11y.change(f);
};

Here you are defining a new function called a11y and inside the definition of that function you are calling a method 'change' on the function a11y being defined. I'm surprised that works in any browser.