最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it possible to detect what action causes page reload? - Stack Overflow

programmeradmin1浏览0评论

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.

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.

Share Improve this question edited Feb 26, 2016 at 13:33 Qwertiy asked Feb 25, 2016 at 18:30 QwertiyQwertiy 21.4k17 gold badges66 silver badges141 bronze badges 6
  • have you tried Monitor Events..it's Chrome plugin... developers.google.com/web/tools/chrome-devtools/debug/… – AAH-Shoot Commented Feb 25, 2016 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 Commented Feb 25, 2016 at 20:15
  • Does this answer your question? Break javascript before an inline javascript redirect in Chrome – Wicket Commented Oct 18, 2022 at 0: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 Commented Oct 18, 2022 at 1:35
  • I know it is years down the track but for anyone else coming this way ..... if you are getting page reloads that you can't track down - it might be a button of type "submit" without a preventDefault on the attached submit function - it does the POST and the browser redirects after the POST. – Duke Dougal Commented Oct 26, 2023 at 23:40
 |  Show 1 more comment

3 Answers 3

Reset to default 14

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

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;
  });
});

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

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

发布评论

评论列表(0)

  1. 暂无评论