Domanda

location.href
location.replace
document.URL

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

È stato utile?

Soluzione

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:

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top