Should I use window.navigate or document.location in JavaScript?
What's the preferred method to use to change the location of the current web page using JavaScript? I've seen both window.navigate and document.location used. Are there any differences in behavior? Are there differences in browser implementations?
window.location.href = 'URL';
is the standard implementation for changing the current window's location.
window.navigate not supported in some browser
In java script many ways are there for redirection, see the below code and explanation
window.location.href = "http://krishna.developerstips.com/";
window.location = "http://developerstips.com/";
window.location.replace("http://developerstips.com/");
window.location.assign("http://work.developerstips.com/");
window.location.href loads page from browser's cache and does not always send the request to the server. So, if you have an old version of the page available in the cache then it will redirect to there instead of loading a fresh page from the server.
window.location.assign() method for redirection if you want to allow the user to use the back button to go back to the original document.
window.location.replace() method if you want to want to redirect to a new page and don't allow the user to navigate to the original page using the back button.
window.location
also affects to the frame,
the best form i found is:
parent.window.location.href
And the worse is:
parent.document.URL
I did a massive browser test, and some rare IE with several plugins get undefined with the second form.
window.location
will affect to your browser target.
document.location will only affect to your browser and frame/iframe.