Displaying objects in IE Developer Tools console
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 w开发者_如何学Pythonhole object as in Visual Studio.
Anyway. Is it possible to make IE Developer Tools console to display object properties and their values?
I use the built in JSON object.
JSON.stringify(my_object)
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.
Try console.dir(/*object*/);
This should give you a little more detail in ie.
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 {...}
.
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])
}
Here's a rather off-the-wall way to do it... run the object through JSON.stringify and display the results of that instead.
Add the object to watch and you can see and analyze it completely from watch panel.
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.
精彩评论