Javascript Safari 开发者工具:如何在导航时保留控制台日志?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14572693/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 17:15:13  来源:igfitidea点击:

Safari Developer Tools: How to Preserve Console Log Upon Navigation?

javascriptdebuggingsafariconsoledeveloper-tools

提问by Zorayr

When using Safari Web Inspectorto read the JavaScript console output, the log is reset upon navigation i.e. going from page index.htmlto mail.htmlclears the console output. In the Chrome Developer Tools, I can easily preserve the log by right clicking on the console space and selecting Preserve Log Upon Navigation. With this option, console log output remains intact until I manually clear the output simplifying the process of debugging JavaScript that refreshes or redirects to another page.

当使用Safari Web Inspector读取 JavaScript 控制台输出时,日志会在导航时重置,即从页面index.html转到mail.html 会清除控制台输出。在Chrome 开发人员工具中,我可以通过右键单击控制台空间并选择在导航时保留日志来轻松保留日志。使用此选项,控制台日志输出将保持不变,直到我手动清除输出以简化调试刷新或重定向到另一个页面的 JavaScript 的过程。

Is there a similar feature in Safari Web Inspector?

Safari Web Inspector 中是否有类似的功能?

采纳答案by Jon

I don't know when this was added, but it is present in Safari on El Capitan (Safari 9.0). It works the same as in Chrome (right click in the console window and select "Keep Log on Navigation").

我不知道这是什么时候添加的,但它存在于 El Capitan (Safari 9.0) 上的 Safari 中。它的工作方式与 Chrome 中的相同(在控制台窗口中右键单击并选择“保持登录导航”)。

Update:As per Daniel Compton's answer, in Safari 11+ this is now under the settings icon as 'Console: Clear when page navigates'.

更新:根据Daniel Compton 的回答,在 Safari 11+ 中,它现在位于设置图标下,为“控制台:页面导航时清除”。

回答by Daniel Compton

In Safari 11.1.2 they moved it again(!) back to the Console tab under the "Preserve log" checkbox. The Network log has similarly moved back to the Network tab.

在 Safari 11.1.2 中,他们再次(!)将其移回“保留日志”复选框下的“控制台”选项卡。网络日志也同样移回了网络选项卡。

Console tab

控制台选项卡



In Safari 11 they moved it to the Settings panel under "Console: Clear when page navigates". It also has a sister setting "Network: Clear when page navigates".

在 Safari 11 中,他们将其移至“控制台:页面导航时清除”下的“设置”面板。它还有一个姊妹设置“网络:页面导航时清除”。

enter image description here

在此处输入图片说明

回答by rvighne

No, there is no such feature (in Safari 5.0 at least). Looking at some Google results, I don't think this feature exists in anySafari version.

不,没有这样的功能(至少在 Safari 5.0 中)。查看一些 Google 结果,我认为任何Safari 版本中都不存在此功能。

回答by gabo bernal

For old Safari versions, you can right-click on the console and select the Keep Log on Navigationenter image description here

对于旧的 Safari 版本,您可以右键单击控制台并选择 Keep Log on Navigation在此处输入图片说明