1

Why is the behavior different between Chrome and IE11 when making two window.location.href assignments in a row?

Chrome ignores the first assignment and will only issue a request for the last one.
IE11 will send a request for the both.

Repro'd here.
NOTE: You'll need to use a tool that can track the outbound requests like fiddler or similar to see the request go out on IE11.

johntrepreneur
  • 4,514
  • 6
  • 39
  • 52
  • here are more info on assigning multiple handlers to an event: http://stackoverflow.com/questions/1491718/jquery-more-than-one-handler-for-same-event As stated in Brad's answer below, browsers do behave differently; it's gradually getting better, though – Manube Jul 10 '16 at 06:48
  • @Manube I would argue in this case that the differences between the browsers is totally fine. I can't think of any circumstance where someone would expect the browser to *not* go to the next URL as instructed by their code. And, it's not as if the JS app has to do anything, as it's expected to be destroyed by will of the user at any time. – Brad Jul 10 '16 at 06:58

1 Answers1

4

It's up to the browser how to implement things like setting the location. One browser probably begins tearing down immediately, and the other probably continues running JavaScript until it's time for the next page to load. In Chrome, it is probably making both requests but the first is cancelled so quickly that it never actually makes it out of the browser.

Brad
  • 159,648
  • 54
  • 349
  • 530