if(window.console){
var cons = console;
if(cons){
var timer = null;
name = 0;
timer = setTimeout(f(name),1000);
}
}
function f(name){
return function(){t(name);}
}
function t(name){
if(name < 10){
cons.log("请在邮件中注明%c来自:console"+name,"color:red;font-weight:bold;");
name++;
timer = setTimeout(f(name),1000);
}else{
clearTimeout(timer);
}
}
window.console 判断当打开浏览器控制台时,执行脚本。