Chrome Dev Tools: How to trace network for a link that opens a new tab?

后端 未结 10 2043
我在风中等你
我在风中等你 2020-12-04 05:23

I want to trace the network activity that happens when I click on a link. The problem is that the link opens a new tab, and apparently the Dev Tools works per tab it was ope

相关标签:
10条回答
  • 2020-12-04 05:29

    In Chrome 85 "Auto-open DevTools for popups" is hidden in a new place

    DevTools (F12)/DevTool Settings (F1, Ctrl + ?)/Preferences/Global

    And now it keeps the "Preserve log" setting.

    0 讨论(0)
  • 2020-12-04 05:32

    I would just let the new tab open, do a F12 and refresh the tab so it logs in the devtools window

    0 讨论(0)
  • 2020-12-04 05:35

    The feature request mentioned in the comment by phsource has been implemented.

    In recent versions (starting with Chrome 50), you can go to the Developer Tools Settings menu (open Developer Tools, then use the 3-dots menu or hit F1) and check the box that says "Auto-open DevTools for popups".

    0 讨论(0)
  • 2020-12-04 05:40

    You can do it this way :

    1. set target="any_window_name" on wanted link.
    2. click on that link once, to open it in new tab.
    3. In opened tab, open developer tools.
    4. 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

    0 讨论(0)
  • 2020-12-04 05:42

    In case the opened link does not redirect, you can open the Network tab in the new tab then refresh the tab.

    0 讨论(0)
  • 2020-12-04 05:43

    Check out chrome://net-internals/#events (or chrome://net-export in the latest version of Chrome) for a detailed overview of all network events happening in your browser.


    Other possible solution, depending on your specific problem, may be to enable 'Preserve log' on the 'Network' tab:

    DevTools > Network > Preserve log

    and force all links to open in the same tab by executing the following code in the console:

    [].forEach.call(document.querySelectorAll('a'),
        function(link){
            if(link.attributes.target) {
                link.attributes.target.value = '_self';
            }
        });
    
    window.open = function(url) {
        location.href = url;
    };
    
    0 讨论(0)
提交回复
热议问题