登录到 Safari JavaScript 控制台
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3748809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Log to Safari JavaScript Console
提问by adib
Is there any way to log to Safari's JavaScript console when running with the built-in JavaScript debugger? I've read the Firefox JavaScript loggingquestion and hoping that there is a simple ("native") way to do it in WebKit/Safari.
使用内置的 JavaScript 调试器运行时,有没有办法登录到 Safari 的 JavaScript 控制台?我已经阅读了Firefox JavaScript 日志记录问题,并希望在 WebKit/Safari 中有一种简单(“本机”)的方法来做到这一点。
Thanks
谢谢
采纳答案by Cristian Sanchez
You can use the same console
object described in that question. The messages will show up in the console tab.
您可以使用该console
问题中描述的相同对象。消息将显示在控制台选项卡中。
console.log("hello console");
console.log
will work "natively" in Firefox (with Firebug), IE8+, and WebKit browsers (including Safari).
console.log
将在 Firefox(带有 Firebug)、IE8+ 和 WebKit 浏览器(包括 Safari)中“本地”工作。
回答by Boris
In the top right corner of the dev tools change Errorsto All.
在开发工具的右上角,将Errors更改为All。
By default, Safari is set to only show console.error()
.
默认情况下,Safari 设置为仅显示console.error()
.
回答by Robert
It works just the same in Safari as it does in Chrome and Firefox. By default the developer tools is not turned on, so make sure you go to Preferences -> Advanced -> Show Develop Menu in Menu Bar
. Then you can pull up the console with Command+Option+C. (That shortcut obviously assumes Mac, not sure the PC shortcut, but it's in the dropdown as well)
它在 Safari 中的工作方式与在 Chrome 和 Firefox 中的工作方式相同。默认情况下,开发人员工具未打开,因此请确保转到Preferences -> Advanced -> Show Develop Menu in Menu Bar
。然后你可以用Command+Option+C调出控制台。(该快捷方式显然假定为 Mac,不确定 PC 快捷方式,但它也在下拉列表中)