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.


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).

| improve this answer | |
  • It was a JavaScript based redirect, but I needed the rest of the JavaScript working. I'll add this to my question. – Xonatron Feb 10 '12 at 14:46
  • @Matthew Doucette Unfortunately, that may not be possible in Firefox: superuser.com/questions/353339/… Mozillazine forums and my own testing say CAPS (selectively disabling JS function) won't work with window.location. Perhaps there is another method. – Bob Feb 10 '12 at 15:46
  • @MatthewDoucette You can intercept the response with a debugging proxy to remove the redirects before they get there. I've updated my answer to add that. (a bit late, but... yea) – Bob May 6 '14 at 7:58

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.