Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想和几个朋友开个玩笑。因为我不想在每个页面都多打几次服务器,所以我希望代码短路,所以只有当这个人有 firebug 或 chrome 控制台时才会执行。
有没有办法检测他们是否正在使用控制台?
如果你很好奇,因为除非在控制台中才能看到这个笑话
我认为你需要的是:
if (typeof window.console != 'undefined') { // Console is available. Do something. }