﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-ddrcam-文章分类-开发工具</title><link>http://www.blogjava.net/ddrcam/category/23661.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 16 Jul 2007 19:07:26 GMT</lastBuildDate><pubDate>Mon, 16 Jul 2007 19:07:26 GMT</pubDate><ttl>60</ttl><item><title>FireBug 控制台函数说明</title><link>http://www.blogjava.net/ddrcam/articles/126940.html</link><dc:creator>黑鸦白羽</dc:creator><author>黑鸦白羽</author><pubDate>Thu, 28 Jun 2007 15:16:00 GMT</pubDate><guid>http://www.blogjava.net/ddrcam/articles/126940.html</guid><wfw:comment>http://www.blogjava.net/ddrcam/comments/126940.html</wfw:comment><comments>http://www.blogjava.net/ddrcam/articles/126940.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ddrcam/comments/commentRss/126940.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ddrcam/services/trackbacks/126940.html</trackback:ping><description><![CDATA[&nbsp;firebug：firefox的一个插件，可以用来调试网页、Ajax，实时编辑网页，终于告别alert了。<br><br>官方网址：<a title=firebug的官方网址 href="http://getfirebug.com/"><a href="http://getfirebug.com/">http://getfirebug.com/</a><br></a>原文地址：<a href="http://www.joehewitt.com/software/firebug/docs.php"><u><font color=#0000ff>http://www.joehewitt.com/software/firebug/docs.php</font></u></a>
<blockquote>
<p><a href="http://www.joehewitt.com/software/firebug/"><u><font color=#0000ff>FireBug</font></u></a> 是一个非常实用的JavaScript以及DOM查看调试工具，是 Firefox 的一个插件。使用 FireBug 调试 AJAX 应用非常方便，终于可以告别 alert 时代了！ </p>
<p>Console Logging 函数<br>FireBug 为所有 Web 页面提供了一个 console 对象。这个对象有以下函数：</p>
<p>Logging 基础<br>console.log("message" [,objects]) - 将一个字符串打印到控制台。字符串可以包含任何&#8220;String Formatting&#8221;小节描述的模式。字符串后面的对象应该用来取代之前字符串中的模式。（译者注：大家用过C里面 printf 吧，效果基本是一样的。）<br><br><br>Logging 等级<br>通常根据不同的等级来区分Logging的严重程度是很有帮助的。FireBug 提供了4个等级。为了达到视觉分离的效果，这些函数与 log 不同的地方就是它们在被调用的时候会自动包含一个指向代码行数的链接。</p>
<p>console.debug("message" [,objects]) - 记录一个 debug 消息。<br>console.info("message" [,objects]) - 记录一个信息.<br>console.warn("message" [,objects]) - 记录一个警告.<br>console.error("message" [,objects]) - 记录一个错误.<br><br><br>断言<br>断言是一条确保代码规则的非常好的途径。console 对象包含了一系列各种类型的断言函数，并且允许你编写自己的断言函数。</p>
<p>console.assert(a, "message" [,objects]) - Asserts that an a is true.<br>console.assertEquals(a, b, "message" [,objects]) - Asserts that a is equal to b.<br>console.assertNotEquals(a, b, "message" [,objects]) - Asserts that a is not equal to b.<br>console.assertGreater(a, b, "message" [,objects]) - Asserts that a is greater than b.<br>console.assertNotGreater(a, b, "message" [,objects]) - Asserts that a is not greater than b.<br>console.assertLess(a, b, "message" [,objects]) - Asserts that a is less than b.<br>console.assertNotLess(a, b, "message" [,objects]) - Asserts that a is not less than b.<br>console.assertContains(a, b, "message" [,objects]) - Asserts that a is in the array b.<br>console.assertNotContains(a, b, "message" [,objects]) - Asserts that a is not in the array b.<br>console.assertTrue(a, "message" [,objects]) - Asserts that a is equal to true.<br>console.assertFalse(a, "message" [,objects]) - Asserts that a is equal to false.<br>console.assertNull(a, "message" [,objects]) - Asserts that a is equal to null.<br>console.assertNotNull(a, "message" [,objects]) - Asserts that a is not equal to null.<br>console.assertUndefined(a, "message" [,objects]) - Asserts that a is equal to undefined.<br>console.assertNotUndefined(a, "message" [,objects]) - Asserts that a is not equal to undefined.<br>console.assertInstanceOf(a, b, "message" [,objects]) - Asserts that a is an instance of type b.<br>console.assertNotInstanceOf(a, b, "message" [,objects]) - Asserts that a is not an instance of type b.<br>console.assertTypeOf(a, b, "message" [,objects]) - Asserts that the type of a is equal to the string b.<br>console.assertNotTypeOf(a, b, "message" [,objects]) - Asserts that the type of a is not equal to the string b.<br><br><br>测量（Measurement）<br>下面的一些函数可以让你方便的测量你的一些代码。</p>
<p>console.trace() - 记录执行点的堆栈信息。<br>console.time("name") - 根据 name 创建一个唯一的计时器。<br>console.timeEnd("name") - 根据 name 停止计时器，并且记录消耗的时间，以毫秒为单位。<br>console.count("name") - 记录该行代码执行的次数。<br><br><br>字符串格式化<br>所有 console 的 logging 函数都可以通过以下模式格式化字符串： </p>
<p>%s - 将对象格式化为字符串。<br>%d, %i, %l, %f - 将对象格式化为数字。<br>%o - 将对象格式化成一个指向 inspector 的超链接。<br>%1.o, %2.0, etc.. - 将对象格式化成包含自己属性的可交互的表格。<br>%.o - 将对象格式化成具有自身属性的一个数组。<br>%x - 将对象格式化成一个可交互的 XML 树形结构。<br>%1.x, %2.x, etc.. - 将对象格式化成一个可交互的 XML 数型结构，并且展开 n 层节点。<br>如果你需要一个真实的 % 符号，你可以通过一个转移符号就像这样 "\%"。 <br></p>
<p>命令行函数<br>内建的命令行函数可以通过以下命令行使用： </p>
<p>$("id") - document.getElementById() 的简写。（译者注：跟 prototype.js 学来的吧？）<br>$$("css") - 返回一个符合 CSS 选择器的元素数组。<br>$x("xpath") - 返回一个符合 XPath 选择器的元素数组。<br>$0 - 返回最近被检查（inspected）的对象。<br>$1 - 返回最近被检查（inspected）的下一个对象。<br>$n(5) - 返回最近被检查的第n个对象。<br>inspect(object) - 将对象显示在 Inspector 中。<br>dir(object) - 返回一个对象的属性名数组。（译者注：跟 Python 学的？）<br>clear() - 清除控制台信息。</p>
</blockquote>
<img src ="http://www.blogjava.net/ddrcam/aggbug/126940.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ddrcam/" target="_blank">黑鸦白羽</a> 2007-06-28 23:16 <a href="http://www.blogjava.net/ddrcam/articles/126940.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>