Debug webpage redirects in browser

In Chrome there is Event Listener Breakpoints -> Sript -> Script First Statement:

Breakpoint on Srcipt First Statement

Pressing F8 will stop on first statement of any script in page, e.g :

<script type="text/javascript">document.location.href='http://www.example.com'</script>   

Also, there is Event Listener Breakpoints -> Load -> beforeUnload but not works in my case.


Alright so it sounds that you want to actually look at variables inside the browser before the redirect occurs. One way I can think of (without modifying the source directly) is to use Google Chrome Snippets.

You could create you're own snippet that binds to the onbeforeunload event.

Step By Step Instructions on Creating a Snippet

Snippet code:

window.onbeforeunload = function(){ 
var debug;
return;
}

All I am doing in the above code is attaching an event before the browser would be redirected.

Visual of chrome

If you then place a break point inside your snippet you will be able to break and inspect the variables on the page. (Don't forget to right click your snippet and select Run) before debugging.


In chrome, in the debug window, at the very bottom, are a series of buttons. Click the button that is a dark black circle. It will preserve the log upon navigation. I think that is what you want.