Displaying objects in IE Developer Tools console

2019-02-02 21:54发布

问题:

I'm debugging my web application in Firefox, Chrome and Internet Explorer. With the latter I'm using Developer Tools to debug my scripts.

The problem I'm having is that when I write some expression in console window and it should return an object all I can see is a simple {...} which isn't really helpful.

Is it possible to make it work similar to Firebug or Chrome console that actually display object content. Chrome is the best in this regard, because you can directly traverse the whole object as in Visual Studio.

Anyway. Is it possible to make IE Developer Tools console to display object properties and their values?

回答1:

If the Prototype API is an option, you can debug your objects like so:

var obj = window.JSON.parse('{"d":"2010-01-01T12:34:56Z","i":123}');
alert($H(obj).inspect());

Other than that, I know of no other way to not get the really helpful {...}.



回答2:

I use the built in JSON object.

JSON.stringify(my_object)


回答3:

To explore an object's properties and values in IE you must first:

  • Have a breakpoint set (or script debugging enabled)
  • Trigger the breakpoint (or encounter an error)

The locals tab has the properties and details locally available at the time the breakpoint was triggered Adding an object name to the watch tab you can view the properties and details of the named object

Our "friends" at Microsoft have a video describing IE's developer tool. At 3:03 is when they mention this "easy" way to explore objects.



回答4:

Try console.dir(/*object*/); This should give you a little more detail in ie.



回答5:

Try this in the console script window:

for (var a in object) {
    console.log("object["+a+"]="+object[a])
}

For example,

for (var a in document.head){
    console.log("document.head["+a+"]="+document.head[a])
}


回答6:

Here's a rather off-the-wall way to do it... run the object through JSON.stringify and display the results of that instead.



回答7:

Add the object to watch and you can see and analyze it completely from watch panel.



回答8:

What works for me and this may just be something they added recently but after you pull up the console log. Clear the log but leave the console open then refresh the page. As the page loads in, you should then be able to explore the objects. I am not sure why it needs to be done that way but it appears to work.