console.log输出自定义颜色的控制台信息

发布:2015-01-22 08:24   点击616次   评论:0

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;");

关于 GitHub 导航 部门 反馈

提示:`/home.php`入口数据仅为演示功能,不构成任何交易凭证,也不承担相关风险和责任!

Copyright © 2011-2018 xxxxx.com All rights reserved.

Run:2.118/27.411(ms); 7(sql)/2.879(MB); comm:news/detail; Upd:2024-11-15 19:46:44