console.log输出自定义颜色的控制台信息
http://xx_yy.com/r/14966
小马如下:
try{
if(window.console&&window.console.log){
console.log("xx_yy.com");
console.log("%c我是红色!!!","color:red");
console.log("xx_yy.com");
}
}catch(e){}
下面是console.log() API的官方文档摘要:
%s
Formats the value as a string.
%d or %i
Formats the value as an integer.
%f
Formats the value as a floating point value.
%o
Formats the value as an expandable DOM element (as in the Elements panel).
%O
Formats the value as an expandable JavaScript object.
%c
Formats the output string according to CSS styles you provide.
下面是一个例子:
console.log("%c xx_yy.com/xx_yy.com/xx_yy.com/xx_yy.com/", "width:50px;height:50px;padding:50px;background:url('http://xx_yy.com/file/webface/29.gif') no-repeat;");