問題描述
使用 Safari Web Inspector 讀取 JavaScript 時控制臺輸出,日志在導航時重置,即從頁面 index.html 到 mail.html 會清除控制臺輸出.在 Chrome 開發者工具中,我可以通過右鍵單擊控制臺空間來輕松保存日志,然后選擇在導航時保留日志.使用此選項,控制臺日志輸出將保持不變,直到我手動清除輸出,從而簡化了刷新或重定向到另一個頁面的 JavaScript 調試過程.
When using Safari Web Inspector to read the JavaScript console output, the log is reset upon navigation i.e. going from page index.html to mail.html clears 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 中是否有類似的功能?
Is there a similar feature in Safari Web Inspector?
推薦答案
我不知道這是什么時候添加的,但它存在于 El Capitan 上的 Safari(Safari 9.0)中.它與 Chrome 中的工作方式相同(在控制臺窗口中單擊鼠標右鍵并選擇保持登錄導航").
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").
更新:根據 Daniel Compton 的回答,現在在 Safari 11+ 中設置圖標為控制臺:頁面導航時清除".
Update: As per Daniel Compton's answer, in Safari 11+ this is now under the settings icon as 'Console: Clear when page navigates'.
更新:設置現在恢復為保留日志".在 Safari 14+ 的開發者控制臺中的網絡"選項卡中
Update: The setting is now back to "Preserve log" in the Network tab in the developer console in Safari 14+
這篇關于Safari 開發者工具:如何在導航時保留控制臺日志?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!