> To answer my own thought, I remembered it's a problem with > the way many external COM controls work because they're not > native Javascript objects. > This post explains the situation a bit: > > http://blogs.msdn.com/ericlippert/archive/2004/09/20/231852.aspx > > Although IE cooperates with Javascript, it seems like MSXML > does not. As a result, Javascript ends up trying to call the > method rather than just seeing if it exists.
Hmm... That's not what Eric's blog post says: - - - - - So here's what happens when you say foo = document.write; First, JScript attempts to resolve "document". It can't find a local or global variable called that, so it asks the global window object for the document property. IE gives back the document object. JScript then asks the document object to give back the value of the write property. IE creates an object which has a default method. The default method calls the write function, but no one calls the method yet -- we just have an object which, when invoked, will call the mehtod. JScript assigns the object to foo. Then when you call foo("hello"); JScript invokes the default method on the object, which calls the write method. The WSH object model was not designed with this in mind. It does not make a distinction between naming a function and calling it, so you can't use this trick. WScript.Echo; does not give back a function object that can be invoked later. - - - - - In other words, in *WSH* you can't just take a reference to a function like WScript.Echo without actually calling it. But IE creates a shim object just for this purpose - so you can save a reference to document.write and similar methods without calling them. > The take-away for jQuery: When checking for a method in a > non-native COM object (MSXML, XMLHTTPRequest, others?) use > typeof(x.method)=="undefined" > and not x.method==undefined . In a quick search I didn't > find any other cases of this in jQuery.js, as long as you > don't jQuery.extend() a non-native COM object--and you shouldn't! I wasn't following the discussion, so I'm not saying your conclusion isn't valid - just that Eric's article doesn't seem to indicate that this would be required. Perhaps this case is different from the document.write example he gave? -Mike _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/