Pop Stack
Pop Stack

Reputation: 944

JavaScript: Ways to open a new page in the same window

location.href
location.replace
document.URL

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

Upvotes: 0

Views: 4448

Answers (1)

Zeta
Zeta

Reputation: 105876

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:

Upvotes: 1

Related Questions