Well, after trying to find what the problem was with my script (it was working well in Firefox, but not in IE, sounds familiar??) I realized that Internet Explorer doesn’t like null to be passed as the second parameter to Function.apply…
According to Mozilla’s documentation, the second parameter to Function.apply should be:
An argument array for the object, specifying the arguments with which
funshould be called, ornullor undefined if no arguments should be provided to the function.
Since I was using apply only to bind this I decided to pass null as the second parameter… apparently IE doesn’t like that… After a bit of searching I found out that with IE, if you want to use Function.apply and not pass any parameter, you should just omit the second parameter or else IE will throw a “TypeError” if your parameter is not an array. So basically just use:
myfunction.apply(this);
Instead of:
myfunction.apply(this, null);
It will work in Mozilla since, as they mention in their doc, the second argument can be null or undefined so… all is well, and everyone is happy!…