Pergunta

location.href
location.replace
document.URL

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

Foi útil?

Solução

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:

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top