IE native functions "bug"?

December 28th, 2008 tim Leave a comment Go to comments

In my article about method closures I showed a way to neatly create a portable reference to an object method that doesn’t  ‘forget’ the object it belongs to. I have since discovered an aggravating problem on – you’ll never guess – Internet Explorer!

It only affects native objects, e.g. window.alert. Before testing any complex code you can see that there is a problem by simply doing the following:

alert( typeof window.alert );

You would expect this to alert “function”, but it does not. It alerts “object”, which explains the result of the next test.

alert( window.alert.call );

You would expect this to alert “function” too, but it is actually undefined. The alert method of the window object is apparently not a Function object, which explains a lot of the IE-specific problems you encounter when you mess about with native objects.

  1. January 3rd, 2009 at 17:21 | #1

    I’ve added a more extensive article about this on the JASPA WIKI:
    See http://jaspa.org.uk/wiki/Method_closure#Microsoft_Internet_Explorer

  1. No trackbacks yet.