我想跟踪单击链接时发生的网络活动。问题是这个链接打开了一个新标签,显然开发工具在每个打开的标签上都能工作。“在导航时保存日志”没有帮助。

我目前的解决方案是移动到FireFox和HttpFox没有这个问题。我想知道Chrome的开发人员是如何管理的,这听起来相当基本(当然我已经搜索了答案,没有找到任何有用的东西)。


当前回答

你可以这样做:

set target="any_window_name" on wanted link. click on that link once, to open it in new tab. In opened tab, open developer tools. go back to origin page and hit that link again. The result will be loaded in already prepared window with developer tools opened. You can activate "preserve log" option in dev tools (see in Konrad Dzwinel excellent answer) to catch any redirect traffic on that link. Note : most people familiar with link target ∈ { _self,_blank,_parent,_top }. But actually any name can be given, this will open a new window with that name, and any subsequent clicks on links,forms or window.open with same target value will be opened in same window. further reading - mdn : window.open , mdn : <a> tag

其他回答

检查chrome://net-internals/#events(或chrome://net-export在最新版本的chrome)的所有网络事件发生在你的浏览器的详细概述。


其他可能的解决方案,取决于你的具体问题,可能是在“网络”选项卡上启用“保存日志”:

并通过在控制台中执行以下代码强制所有链接在同一个选项卡中打开:

[].forEach.call(document.querySelectorAll('a'),
    function(link){
        if(link.attributes.target) {
            link.attributes.target.value = '_self';
        }
    });

window.open = function(url) {
    location.href = url;
};

在Chrome 61.0.3163.100,你现在有以下选项可用。 它是通过去Chrome开发工具设置访问。它在底部。

如果打开的链接没有重定向,您可以在新选项卡中打开Network选项卡,然后刷新该选项卡。

在Chrome 85中(在Chrome 100中仍然有效)“自动打开弹出式开发工具”被隐藏在一个新的地方

DevTools (F12)/Settings (F1, Ctrl + ?)/Preferences/Global(在列表的末尾)

现在它保留了“保存日志”的设置。

你可以这样做:

set target="any_window_name" on wanted link. click on that link once, to open it in new tab. In opened tab, open developer tools. go back to origin page and hit that link again. The result will be loaded in already prepared window with developer tools opened. You can activate "preserve log" option in dev tools (see in Konrad Dzwinel excellent answer) to catch any redirect traffic on that link. Note : most people familiar with link target ∈ { _self,_blank,_parent,_top }. But actually any name can be given, this will open a new window with that name, and any subsequent clicks on links,forms or window.open with same target value will be opened in same window. further reading - mdn : window.open , mdn : <a> tag