My extension should perform URL redirection on certain URL patterns.
This should happen for all HTTP requests.
The closest I got to is to add my progress listenert with
addProgressListener()
and then, in onStateChange(), in case of flag indicating STATE_START,
then changing window.document.location.href. However this does not
work
right, after the redirection somehow the all the bars (menu, toolbar,
location,
bookmarks) dissappear and I don't even see the redirection happenning
again.
Do you have any suggestions?
Marko
I was able to get this to work in FF 3.0.4 by using the following code
inside my onStateChange() handler:
if ( (aFlag & (STATE_IS_DOCUMENT|STATE_START)) && doTriggerRedirect ) {
aRequest.cancel( 0x804b0002 ); // NS_BINDING_ABORTED
gBrowser.loadURI( redirect_url );
doTriggerRedirect = false;
}
The only other trick is that you probably want the redirect to trigger
only once, so I used the doTriggerRedirect global flag.
The magic to cancel the pending request is due to
t...@gigasoftdevelopment.com who posted about this a few months ago.
hth,
joe
Does anybody know what's wrong? I've tried replacing STATE_IS_DOCUMENT
with STATE_IS_NETWORK, and also removing it entirely, and neither of
these helps.
joe
gURLBar.value = newurl; // sets the location bar value
handleURLBarCommand(); // loads the URL in the location bar
works like a charm!