16

Unknown script action (probably async) causes page reload.

How can I find this action in the code?

At least, is there any way to set breakpoint on access to window.location?
But I'm not sure that navigation is forced in such way.

In fact I need a way working in any one browser as page reloads in any of them.

PS: Same question in Russian.

Qwertiy
  • 19,681
  • 15
  • 61
  • 128
  • have you tried Monitor Events..it's Chrome plugin... https://developers.google.com/web/tools/chrome-devtools/debug/command-line/events?hl=en – AAH-Shoot Feb 25 '16 at 18:37
  • 1
    @AAH-Shoot, if you mean `beforeunload` or `unload` - seems like they can't help me as they do not contain stack trace and I can't detect reason of reload there? Or there is a way? Or you have meant some other events? – Qwertiy Feb 25 '16 at 20:15
  • Does this answer your question? [Break javascript before an inline javascript redirect in Chrome](https://stackoverflow.com/questions/12360187/break-javascript-before-an-inline-javascript-redirect-in-chrome) – Rubén Oct 18 '22 at 00:55
  • @Rubén, the question is the same, but 2 of 3 unswers there are not working, the 3rd is hard to use (actually not sure if it works for all cases). I think, answers here are better. – Qwertiy Oct 18 '22 at 01:35

3 Answers3

13

Try opening the Network panel, enabling Preserve log (which saves the network activity log between page loads) and then recreating the behavior.

https://stackoverflow.com/a/25734475/1669860

Community
  • 1
  • 1
Kayce Basques
  • 23,849
  • 11
  • 86
  • 120
  • 1
    In Firefox you can click on a network request and then on the tab "Stack Trace" to see which JS code triggered the navigation. – MarcDefiant Feb 11 '20 at 12:21
2

Better solution for me was to handle unload / beforeunload page events and watch stack trace on debugger breakpoint.

['unload', 'beforeunload'].forEach(function (eventName) {
  window.addEventListener(eventName, function () {
    debugger;
  });
});
Qwertiy
  • 19,681
  • 15
  • 61
  • 128
PokatilovArt
  • 1,111
  • 11
  • 13
-7

have you tried firebug?? free add-on https://getfirebug.com/downloads

It gives many options to debug.
give it a try.

nilesh
  • 191
  • 5
  • 20
  • 1
    Every devtools have many possibilities. But I'm searching for a concrete thing. If it is possible using firebug I would like to know how. – Qwertiy Feb 25 '16 at 20:16