Question

location.href
location.replace
document.URL

As seen from other similar questions, can we consolidate all such possible methods?

Was it helpful?

Solution

var customURL = 'http://www.example.com';
window.location.href = customURL;
window.location.assign(customURL);

// Current page won't get saved in the history:
window.location.replace(customURL); 


// Gecko only:
window.document.location = customURL

See also:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top