惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
L
LangChain Blog
云风的 BLOG
云风的 BLOG
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
小众软件
小众软件
WordPress大学
WordPress大学
A
About on SuperTechFans
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
Jina AI
Jina AI
T
Tailwind CSS Blog
Google DeepMind News
Google DeepMind News
D
Docker

博客园 - flykye

FLEX内存优化技巧集合 在FF下用CSS模拟实现text-overflow:ellipsis字符截取省略号效果 - flykye - 博客园 FireBug的控制台管理 推介的CSS书写顺序(转) CSS实现未知高度图文混合垂直居中 JavaScript与ActionScript通讯 JavaScript继承之闭包原型继承法 JavaScript在内层循环中断外层循环 我的Blog不含三聚氰胺 傲游越来越差了 IE下LI的3pxBUG IE下使用CSS截取文字 调试JavaScript,不再用alert了 firefox的css私有属性 scrollLeft,scrollWidth,clientWidth,offsetWidth之完全详解 页面优化技巧 javascript拖动小例子 Firefox下的__proto__ IE7 IE6 FF 简单的CSS Hack
调试JavaScript,不再用alert了 (二)
flykye · 2008-10-03 · via 博客园 - flykye

Firebug的Console API

每个用Firefox加载的页面,Firebug都添加了一个全局变量console,通过这个变量的若干方法,你可以通过脚本向控制台输出各种调试信息。

console.log(object[, object, ...])

往控制台写一条信息,可以有多个参数,甚至可以像printf那样格式化出去,例如

console.log("The %s jumped over %d tall buildings", animal, count);

或者这样:

console.log("The", animal, "jumped over", count, "tall buildings");
console.log("I am %s and I have:", myName, thing1, thing2, thing3);
下面是格式化参数表:
String Substitution Patterns
%s String
%d, %i Integer (numeric formatting is not yet supported)
%f Floating point number (numeric formatting is not yet supported)
%o Object hyperlink

console.debug(object[, object, ...])

向控制台输出一条信息,同时包含了跳往调用行的链接

console.info(object[, object, ...])

向控制台输出一条信息,前面显示“信息”图标,同样包含了跳往调用行的链接

console.warn(object[, object, ...])

向控制台输出一条信息,前面显示“警告”图标,同样包含了跳往调用行的链接

console.error(object[, object, ...])

向控制台输出一条信息,前面显示“错误”图标,同样包含了跳往调用行的链接

console.assert(expression[, object, ...])

校验是否符合表达式,如果不符合,将向控制台输出错误信息,并且抛出异常

console.dir(object)

输出对象的所有属性,可以在DOM标签中看到详细信息

console.dirxml(node)

输出HTML或XML元素的XML代码树,可以再HTML中查看详细的情况

console.trace()

Prints an interactive stack trace of JavaScript execution at the point where it is called.

The stack trace details the functions on the stack, as well as the values that were passed as arguments to each function. You can click each function to take you to its source in the Script tab, and click each argument value to inspect it in the DOM or HTML tabs.

console.group(object[, object, ...])

分组输出,和console.groupEnd()配合使用,知道下一个console.groupEnd()出现,就闭合分组

console.groupEnd()

和console.group()配合使用

console.time(name)

创建一个定时器,知道调用console.time(name),才停止该定时器计时

console.timeEnd(name)

和console.time(name)配合使用

console.profile([title])

Turns on the JavaScript profiler. The optional argument title would contain the text to be printed in the header of the profile report

console.profileEnd()

Turns off the JavaScript profiler and prints its report

console.count([title])

 计数器,每执行一次,该title的值就累加1