Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firefox and javascript redirection

I currently have a issue with firefox, where all other browser behave in the right way - even IE6!

What I want to do is redirection to a subpage but leaving a history entry. There are 2 methods of rewriting the url as far as I know:

  • window.location = "some.url"; - redirect to some.url with history entry
  • window.location.replace("some.url"); - redirect without history entry

So I have to use the first one and tested in the firebug console everthing works fine.

Now there is the kind of strange part of this question: the same statement, that worked fine in the console doesn't in some jQuery callback handler:

jQuery("#selector").bind("submit", function() {
  $.getJSON("some_cool_json", function(response) {
    var redirect_path = response.path;
    window.location = redirect_path;
  });
  return false;
});

where response_path is set correctly, I checked it! Even the redirection is working correctly, but there is no history entry created.

Any ideas on that one? Would be great! ;)

Cheers

Joe

like image 888
xijo Avatar asked Dec 23 '22 05:12

xijo


1 Answers

use assign():

window.location.assign("http://...");

replace(url)
Replace the current document with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session history, meaning the user won't be able to use the Back button to navigate to it.

like image 150
Phil Rykoff Avatar answered Jan 03 '23 03:01

Phil Rykoff