In Firebug, how can I stop a redirect?

In Firebug, how can I stop a redirect? I want to examine and edit a webpage before it redirects. Under the Net tab, using Persist I can see all the GET including the previous pages and the redirect page, but I am still taken to the final redirect page. I want to stop one move before this. Is it possible?

EDIT: It is a JavaScript based redirect, but I need the rest of the JavaScript working, so blocking all JavaScript from execution is not a solution in this instance.


Solution 1:

What kind of redirect? There are Firefox addons outside of Firebug you can use to stop redirects. Firebug does not seem to provide this functionality itself.

Redirects based on the HTML "Meta refresh" (also HTTP "Refresh") can be blocked by setting accessibility.blockautorefresh to true in about:config. In fact, this corresponds to the "Warn me when web sites try to redirect or reload the page" option in Options > Advanced > General. Alternatively, addons such as RefreshBlocker can be used.

For JavaScript based redirects, JS can be completely disabled or addons such as NoScript can be used.

There generally isn't much you can inspect on a page that is redirected using HTTP 3xx response codes. In case anyone wants to know, setting network.http.redirection-limit to 0 in about:config causes all of these to show a Firefox error page.


JS redirects

JS-based redirects are difficult. I'm not aware of a method to stop them from within the browser. However, you can intercept the responses with a debugging proxy like Fiddler2, and replace it with your own modified response (the AutoResponder in Fiddler2 is one way). In this modified response, you'd want to remove any references to window.location and location, the usual ways to change the page from JS [you might be able to get away with replacing them with a dummy variable, e.g. var thisIsAMadeUpVarName]. That way, the redirect would never get to the browser. See the "Search and replace in HTML." section of this document (you may wish to also filter JS files if they are served separately).

Solution 2:

I know i'm a bit late, but i think the best solution is using Fiddler to block access to the redirected url.

I think adding an autoresponder to that url so that it returns the 204_NoContent.dat response would do the trick. This works at least on Firefox.

Another option might be to return some content in the form of a download using "content-disposition: attachment" so the browser is forced to download it and not change the window content.