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 判斷當打開瀏覽器控制臺時,執(zhí)行腳本拆融。