Search code examples
javascriptandroidandroid-browserwindow.location

window.location failing on Android Browser


I've run into this and while the internet seems to be full of answers and discussions on this issue nothing seems to be working.

I'm building a mobile web page where I run a jQuery JavaScript function off a submit button, it calls an AJAX query comes back does it's business and then I get to the dreaded:

window.location = "url";

Now I've personally tried every version of this I've seen deprecated or not:

window.location.href =
window.location.replace() --I know this is achieving something different
window.location.assign()
window.navigate()
document.location =
document.location.href =
document.location.replace()
document.location.assign()

In each instance my Android Browser version 5.5 just stops at the point it is supposed to move through to the next url. I'm using full urls from the "http://..." so not missing that.

In contrast Android Chrome is moving through like a champ. Same Phone. Have I missed some crucially important piece to the puzzle here to get this moving on Android Browser?

My searches online seem to only say that:

window.location.href = '';

...is the most technically correct, right now I'd settle for working rather than technically correct.

If anyone has any ideas or at least some avenues to go off and explore I'll get all over that first thing in the morning.

Thanks for any help you can offer.


Solution

  • I found that this was a result of a faulty AJAX call. The weird thing that was throwing me off was that some items would work within the call (even though the call failed) and some would not.

    The answer in my own case was to fix the PHP that the AJAX was calling and then changing pages worked as I would expect it to.