Cannot find how a page is redirecting?
When we debug JavaScript, sometimes we cannot find how a page redirects to another page. Normally, it happens when we have lots of JavaScript involved in the web page. Many third-party JavaScripts also make it hard to find.
You can add a breakpoint of window.unload
and window.beforeunload
events in this case. Follow these steps to add a breakpoint:
- Open Chrome DevTools.
- Open the
Sources
tab. - Expand
Event Listener Breakpoints
from the right panel. - Expand the
Load
group from there. - Check
unload
and/orbeforeunload
.
Now, try to replicate the issue, the debugger will block whenever those events will trigger.