简体   繁体   English

JavaScript:在同一窗口中打开新页面的方法

[英]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? 从其他类似问题可以看出,我们可以合并所有这些可能的方法吗?

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: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM