【问题标题】:JavaScript: Ways to open a new page in the same windowJavaScript:在同一窗口中打开新页面的方法
【发布时间】:2012-04-21 09:34:04
【问题描述】:
location.href
location.replace
document.URL

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

【问题讨论】:

标签: javascript html url dom location-href


【解决方案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

另见:

【讨论】:

    猜你喜欢
    • 2010-09-21
    • 1970-01-01
    • 2018-11-27
    • 2011-02-03
    • 2017-03-29
    • 1970-01-01
    • 2012-03-18
    • 2012-06-18
    相关资源
    最近更新 更多