tags:

views:

85

answers:

1

I am building an object/property dump using JavaScript. This code breaks under Internet Explorer 8 (assuming subject = window.external)

// Gather the property names into the keys array.
var keys = Array(); for( var i in subject ){ keys.push(i); }

/* After this I sort the keys, then loop through to get the 
   property values in subject
*/

If you try printing subject to the console (or alert) it comes up blank. However, other objects will print [object SomethingMeaningful].

Microsoft's documentation suggests that the object definitely has properties. It would be nice to be able to show them instead of just skipping over them. Any Ideas?

+1  A: 

Do you mean this?

var keys = Array(); for( var i in subject ){ keys.push(subject[i]); }

You can access object properties with array like syntax in JavaScript

EDIT

Thanks for the edit. I am not sure why that would not work for the window.external object. It may be that it has methods only, and no properties. Does it work under other browsers, for example, Firefox?

alex
No - I am storing the property name in the keys array, not the property itself. The reason for this is that I am sorting the keys (using keys.sort()) before running through the properties.
Works fine for every other object (including objects which only have methods - it dumps the method name, and the first line of the code). IE is the only browser I am aware of that has the window.external object.
I thought firefox had the external object too.. for adding bookmarks?
alex