简体   繁体   English

Facebook 如何像这样登录到控制台?

[英]How does Facebook log to console like this?

I was inspecting stuff, as you do, and came across this interesting thing on facebook.我和你一样在检查东西,在 facebook 上发现了这个有趣的东西。

脸书 View Full Image

I understand that is completely do-able with something similar to this:我知道这完全可以用类似的东西来做:

var cssRule =
    "color: rgb(249, 162, 34);" +
    "font-size: 60px;" +
    "font-weight: bold;" +
    "text-shadow: 1px 1px 5px rgb(249, 162, 34);" +
    "filter: dropshadow(color=rgb(249, 162, 34), offx=1, offy=1);";
console.log("%cHello World", cssRule);

Source 来源

My main question is, How do they stop the showing of the file.js:line_numer that you always get on the right hand side in console?我的主要问题是,他们如何停止显示您总是在控制台右侧看到的 file.js:line_numer

With the above code, you would see this:使用上面的代码,你会看到:规范 View Full Image

Do you notice the red circle?你注意到红圈了吗? But in facebooks example, they don't display that information.但在 facebooks 示例中,他们不显示该信息。 I've looked through the Web.Console API on Mozilla ( Link ), so does anybody possibly know how to exclude that specific peice of information?我已经浏览了 Mozilla ( Link ) 上的 Web.Console API,那么有人可能知道如何排除特定的信息吗?

你只需要异步/推迟console.log调用,例如

setTimeout(console.log.bind(console, '%cFoo', 'color: #FF00FF;'), 0);

Even though I joined the party late but I think this will do!尽管我入党晚了,但我认为这行!

    var cssRule =
    "color: rgb(249, 162, 34);" +
    "font-size: 30px;" +
    "font-weight: bold;" +
    "text-shadow: 1px 1px 5px rgb(249, 162, 34);" +
    "filter: dropshadow(color=rgb(249, 162, 34), offx=1, offy=1);" setTimeout(console.log.bind(console, "%cHello World", cssRule), 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 console.log 的行为是这样的? - Why does console.log behave like this? 如何使log4js打印对象,如console.log - How can I make log4js print objects like console.log does 如何向打开Chrome控制台的用户显示警告,例如Facebook和Blockchain? - How can I display a warning to users who open the Chrome console, like Facebook and Blockchain does? 为什么Firefox不喜欢Facebook登录弹出窗口? - Why does Firefox not like the Facebook Log In popup window? console.log如何工作? - How does console.log work? setTimeout(console.log.bind(console,“ something”))如何工作? - How does setTimeout(console.log.bind(console, “something”)) work? 为什么console.log(10150141932135203)在Firefox和Chrome中打印10150141932135204以及如何处理像这样的大整数值? - Why does console.log(10150141932135203) print 10150141932135204 in both Firefox and Chrome and how to I deal with large integer values like these? 如何在winston中记录JavaScript对象和数组作为console.log呢? - How to log JavaScript objects and arrays in winston as console.log does? 一旦异步Facebook赞按钮被加载(显示),Console.log - Console.log something once async Facebook Like button is loaded (displayed) 为什么这个控制台记录 0? - Why does this console log 0?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM