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

时间:2012-04-21 09:34:04

标签: javascript html url dom location-href

location.href
location.replace
document.URL

从其他类似问题可以看出,我们能否整合所有这些可能的方法?

1 个答案:

答案 0 :(得分:1)

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

另见: