As the others said, you can use Firebug, and that will sort you out no worries on Firefox.
(正如其他人所说,你可以使用Firebug,这样就不用担心Firefox了。)
Chrome & Safari both have a built-in developer console which has an almost identical interface to Firebug's console, so your code should be portable across those browsers.(Chrome和Safari都有一个内置的开发者控制台,它与Firebug的控制台具有几乎相同的界面,因此您的代码应该可以在这些浏览器中移植。)
For other browsers, there's Firebug Lite .(对于其他浏览器,有Firebug Lite 。)
If Firebug isn't an option for you, then try this simple script:
(如果Firebug不适合你,那么试试这个简单的脚本:)
function dump(obj) {
var out = '';
for (var i in obj) {
out += i + ": " + obj[i] + "
";
}
alert(out);
// or, if you wanted to avoid alerts...
var pre = document.createElement('pre');
pre.innerHTML = out;
document.body.appendChild(pre)
}
I'd recommend against alerting each individual property: some objects have a LOT of properties and you'll be there all day clicking "OK", "OK", "OK", "O... dammit that was the property I was looking for".
(我建议不要警告每个属性:一些对象有很多属性,你会在那里整天点击“确定”,“确定”,“确定”,“我......该死的那个属性我是寻找”。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…